File: reproducible-build.patch

package info (click to toggle)
python-quantities 0.16.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 880 kB
  • sloc: python: 8,039; makefile: 75; sh: 3
file content (32 lines) | stat: -rw-r--r-- 1,133 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
26
27
28
29
30
31
32
Description: Make the build reproducible
Author: Chris Lamb <lamby@debian.org>
Forwarded: not-needed
Last-Update: 2024-03-11

--- python-quantities-0.15.0.orig/setup.py
+++ python-quantities-0.15.0/setup.py
@@ -1,8 +1,14 @@
+import os
+import time
 from setuptools import Command, setup
 from setuptools.command.build_py import build_py as _build
 from setuptools.command.sdist import sdist as _sdist
-from datetime import datetime
+from datetime import datetime, timezone
 
+build_date = datetime.fromtimestamp(
+    int(os.environ.get('SOURCE_DATE_EPOCH', time.time())),
+    tz=timezone.utc,
+)
 
 class data(Command):
 
@@ -24,7 +30,7 @@ class data(Command):
         with open('quantities/constants/_codata.py', 'w') as f:
             f.write('# THIS FILE IS AUTOMATICALLY GENERATED\n')
             f.write('# ANY CHANGES MADE HERE WILL BE LOST\n')
-            f.write(f'# LAST GENERATED: {datetime.now()}\n\n')
+            f.write(f'# LAST GENERATED: {build_date}\n\n')
             f.write('physical_constants = {}\n\n')
             for line in data:
                 name = line[:55].rstrip().replace('mag.','magnetic')