Source: pynwb
Version: 1.2.1-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
pynwb could not be built reproducibly.

This is because it embedded the build date into generated ".nwb" files
*but* note that your package is installing files directly under:

  /usr/lib/python3/dist-packages/test_*.nwb

… which is probably not what you intend to happen. Patch attached, but
I would probably rather if your package simply did not install this
test file.

 [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   2020-02-08 14:38:25.778464385 
+0000
@@ -0,0 +1,28 @@
+Description: Make the build reproducible
+Author: Chris Lamb <la...@debian.org>
+Last-Update: 2020-02-08
+
+--- pynwb-1.2.1.orig/src/pynwb/file.py
++++ pynwb-1.2.1/src/pynwb/file.py
+@@ -1,5 +1,6 @@
++import os
+ from datetime import datetime
+-from dateutil.tz import tzlocal
++from dateutil.tz import tzlocal, UTC
+ from collections.abc import Iterable
+ from warnings import warn
+ import copy as _copy
+@@ -306,7 +307,12 @@ class NWBFile(MultiContainerInterface):
+ 
+         self.fields['file_create_date'] = getargs('file_create_date', kwargs)
+         if self.fields['file_create_date'] is None:
+-            self.fields['file_create_date'] = datetime.now(tzlocal())
++            try:
++                file_create_date = 
datetime.utcfromtimestamp(int(os.environ['SOURCE_DATE_EPOCH']))
++                file_create_date = file_create_date.replace(tzinfo=UTC)
++            except KeyError:
++                file_create_date = datetime.now(tzlocal())
++            self.fields['file_create_date'] = file_create_date
+         if isinstance(self.fields['file_create_date'], datetime):
+             self.fields['file_create_date'] = 
[self.fields['file_create_date']]
+         self.fields['file_create_date'] = list(map(_add_missing_timezone, 
self.fields['file_create_date']))
--- a/debian/patches/series     1970-01-01 01:00:00.000000000 +0100
--- b/debian/patches/series     2020-02-08 14:33:13.040208521 +0000
@@ -0,0 +1 @@
+reproducible-build.patch

Reply via email to