Source: snakemake
Version: 6.9.1+dfsg1-3
Severity: wishlist
Tags: patch
User: reproducible-bui...@lists.alioth.debian.org
Usertags: randomness
X-Debbugs-Cc: reproducible-b...@lists.alioth.debian.org

Hi,

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

This is because it generates and ships a Graphviz .dot file during the
tests and this file has a non-deterministic ordering. Also, the PDF
file generated from this very .dot file contains a created date in its
headers.

Patch attached that fixes the non-determinism in the .dot file
generation and prevents the Debian packaging from shipping the
non-deterministic PDF version.

 [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   2021-10-22 09:09:22.433645939 
+0100
@@ -0,0 +1,33 @@
+Description: Make the build reproducible
+Author: Chris Lamb <la...@debian.org>
+Last-Update: 2021-10-22
+
+--- snakemake-6.9.1+dfsg1.orig/snakemake/dag.py
++++ snakemake-6.9.1+dfsg1/snakemake/dag.py
+@@ -1781,7 +1781,7 @@ class DAG:
+         huefactor = 2 / (3 * len(self.rules))
+         rulecolor = {
+             rule: "{:.2f} 0.6 0.85".format(i * huefactor)
+-            for i, rule in enumerate(self.rules)
++            for i, rule in sorted(enumerate(self.rules))
+         }
+ 
+         # markup
+@@ -1850,7 +1850,7 @@ class DAG:
+         huefactor = 2 / (3 * len(self.rules))
+         rulecolor = {
+             rule: hsv_to_htmlhexrgb(i * huefactor, 0.6, 0.85)
+-            for i, rule in enumerate(self.rules)
++            for i, rule in sorted(enumerate(self.rules))
+         }
+ 
+         def resolve_input_functions(input_files):
+@@ -1956,7 +1956,7 @@ class DAG:
+             {items}
+             }}\
+             """
+-        ).format(items="\n".join(nodes + edges))
++        ).format(items="\n".join(sorted(nodes) + sorted(edges)))
+ 
+     def summary(self, detailed=False):
+         if detailed:
--- a/debian/patches/series     2021-10-22 09:05:53.731764374 +0100
--- b/debian/patches/series     2021-10-22 09:09:21.661639882 +0100
@@ -9,3 +9,4 @@
 fix_test_pytest.patch
 python2to3.patch
 hack-around-connectionpool.patch
+reproducible-build.patch
--- a/debian/rules      2021-10-22 09:05:53.731764374 +0100
--- b/debian/rules      2021-10-22 09:06:22.120052643 +0100
@@ -28,7 +28,7 @@
 # Skipped in build due to network use, but run in autopkgtest: test_ancient
 # Tests marked @connected skip themselves in this case
 
-export PYBUILD_AFTER_TEST_python3=rm -fr {build_dir}/bin {build_dir}/tests 
{dir}/tests/test_filegraph/.snakemake/ {dir}/tests/linting/*/.snakemake/
+export PYBUILD_AFTER_TEST_python3=rm -fr {build_dir}/bin {build_dir}/tests 
{dir}/tests/test_filegraph/.snakemake/ {dir}/tests/linting/*/.snakemake/ 
{dir}/tests/test_filegraph/fg.pdf
 
 export PATH:=$(shell pybuild --print build_dir --interpreter python3 --name 
$(PYBUILD_NAME))/bin:$(PATH)
 

Reply via email to