Source: python-quantities Version: 0.15.0-1 Severity: wishlist Tags: patch User: reproducible-bui...@lists.alioth.debian.org Usertags: timestamps X-Debbugs-Cc: reproducible-b...@lists.alioth.debian.org
Hi, Whilst working on the Reproducible Builds effort [0], we noticed that python-quantities could not be built reproducibly. This is because the build process writes a timestamp to a generated file. A patch is attached that sources this timestamp from SOURCE_DATE_EPOCH instead of the system clock. [0] https://reproducible-builds.org/ Regards, -- ,''`. : :' : Chris Lamb `. `'` la...@debian.org / chris-lamb.co.uk `-
--- a/debian/patches/reproducible-build.patch 1970-01-01 01:00:00.000000000 +0100 --- b/debian/patches/reproducible-build.patch 2024-03-11 15:07:58.203181306 +0000 @@ -0,0 +1,31 @@ +Description: Make the build reproducible +Author: Chris Lamb <la...@debian.org> +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') --- a/debian/patches/series 1970-01-01 01:00:00.000000000 +0100 --- b/debian/patches/series 2024-03-11 15:05:38.702459132 +0000 @@ -0,0 +1 @@ +reproducible-build.patch