File: 003.source_date_epoch.patch

package info (click to toggle)
python-pyfunceble 4.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,144 kB
  • sloc: python: 27,918; sh: 142; makefile: 48
file content (25 lines) | stat: -rw-r--r-- 935 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
From: Dmitry Shachnev <mitya57@debian.org>
Date: Sat, 3 Aug 2024 18:02:02 +0300
Subject: Add support for SOURCE_DATE_EPOCH environment variable

This makes the documentation build reproducibly.
Forwarded: https://github.com/funilrys/PyFunceble/pull/376
---
 PyFunceble/downloader/base.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/PyFunceble/downloader/base.py b/PyFunceble/downloader/base.py
index 96ed8f7..c082478 100644
--- a/PyFunceble/downloader/base.py
+++ b/PyFunceble/downloader/base.py
@@ -298,6 +298,10 @@ class DownloaderBase:
         """
 
         current_datetime = datetime.datetime.now(datetime.timezone.utc)
+        if epoch := os.environ.get("SOURCE_DATE_EPOCH"):
+            current_datetime = datetime.datetime.fromtimestamp(
+                float(epoch), datetime.timezone.utc
+            )
 
         self.all_downtimes[self.DOWNTIME_INDEX] = {
             "iso": current_datetime.isoformat(),