Source: logilab-common
Version: 1.7.2-1
Severity: wishlist
Tags: patch
User: reproducible-bui...@lists.alioth.debian.org
Usertags: randomness filesystem
X-Debbugs-Cc: reproducible-b...@lists.alioth.debian.org

Hi,

Whilst working on the Reproducible Builds effort [0] we noticed that
logilab-common could not be built reproducibly.

This is because it embedded the build system's process ID and absolute
build directory in the generated documentation encoded via default
Python keyword arguments.

Patch attached that generates these at runtime instead.

 [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-07-18 10:54:52.109133762 
+0100
@@ -0,0 +1,36 @@
+Description: Make the build reproducible
+Author: Chris Lamb <la...@debian.org>
+Last-Update: 2020-07-18
+
+--- logilab-common-1.7.2.orig/logilab/common/proc.py
++++ logilab-common-1.7.2/logilab/common/proc.py
+@@ -171,12 +171,14 @@ class MemorySentinel(Thread):
+     daemonic thread
+     """
+ 
+-    def __init__(self, interval, memory_limit, gpid=os.getpid()):
++    def __init__(self, interval, memory_limit, gpid=None):
+         Thread.__init__(self, target=self._run, name="Test.Sentinel")
+         self.memory_limit = memory_limit
+         self._stop = Event()
+         self.interval = interval
+         self.setDaemon(True)
++        if gpid is None:
++            gpid = os.getpid()
+         self.gpid = gpid
+ 
+     def stop(self):
+--- logilab-common-1.7.2.orig/logilab/common/pytest.py
++++ logilab-common-1.7.2/logilab/common/pytest.py
+@@ -209,8 +209,10 @@ def load_pytest_conf(path, parser):
+     return namespace.get("CustomPyTester", PyTester)
+ 
+ 
+-def project_root(parser, projdir=os.getcwd()):
++def project_root(parser, projdir=None):
+     """try to find project's root and add it to sys.path"""
++    if projdir is None:
++        projdir = os.getcwd()
+     previousdir = curdir = osp.abspath(projdir)
+     testercls = PyTester
+     conf_file_path = osp.join(curdir, CONF_FILE)
--- a/debian/patches/reproducible-build.patch~  1970-01-01 01:00:00.000000000 
+0100
--- b/debian/patches/reproducible-build.patch~  2020-07-18 10:52:56.886826995 
+0100
@@ -0,0 +1,22 @@
+Description: Make the build reproducible
+Author: Chris Lamb <la...@debian.org>
+Last-Update: 2020-07-18
+
+--- logilab-common-1.7.2.orig/logilab/common/proc.py
++++ logilab-common-1.7.2/logilab/common/proc.py
+@@ -171,12 +171,14 @@ class MemorySentinel(Thread):
+     daemonic thread
+     """
+ 
+-    def __init__(self, interval, memory_limit, gpid=os.getpid()):
++    def __init__(self, interval, memory_limit, gpid=None):
+         Thread.__init__(self, target=self._run, name="Test.Sentinel")
+         self.memory_limit = memory_limit
+         self._stop = Event()
+         self.interval = interval
+         self.setDaemon(True)
++        if gpid is None:
++            gpid = os.getpid()
+         self.gpid = gpid
+ 
+     def stop(self):
--- a/debian/patches/series     1970-01-01 01:00:00.000000000 +0100
--- b/debian/patches/series     2020-07-18 10:52:54.078770568 +0100
@@ -0,0 +1 @@
+reproducible-build.patch
--- a/logilab/common/proc.py    2020-07-18 10:42:16.017506293 +0100
--- b/logilab/common/proc.py    2020-07-18 10:54:01.744127425 +0100
@@ -171,12 +171,14 @@
     daemonic thread
     """
 
-    def __init__(self, interval, memory_limit, gpid=os.getpid()):
+    def __init__(self, interval, memory_limit, gpid=None):
         Thread.__init__(self, target=self._run, name="Test.Sentinel")
         self.memory_limit = memory_limit
         self._stop = Event()
         self.interval = interval
         self.setDaemon(True)
+        if gpid is None:
+            gpid = os.getpid()
         self.gpid = gpid
 
     def stop(self):
--- a/logilab/common/pytest.py  2020-07-18 10:42:16.017506293 +0100
--- b/logilab/common/pytest.py  2020-07-18 10:54:48.529062323 +0100
@@ -209,8 +209,10 @@
     return namespace.get("CustomPyTester", PyTester)
 
 
-def project_root(parser, projdir=os.getcwd()):
+def project_root(parser, projdir=None):
     """try to find project's root and add it to sys.path"""
+    if projdir is None:
+        projdir = os.getcwd()
     previousdir = curdir = osp.abspath(projdir)
     testercls = PyTester
     conf_file_path = osp.join(curdir, CONF_FILE)

Reply via email to