Source: python-scrapy
Version: 2.4.1-2
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-scrapy could not be built reproducibly.

This is because it uses the current build year when building the
documentation which, of course, changes depending which year you
build the software.

Patch attached that uses SOURCE_DATE_EPOCH [1] instead.

 [0] https://reproducible-builds.org/
 [1] https://reproducible-builds.org/specs/source-date-epoch/


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      la...@debian.org / chris-lamb.co.uk
       `-
--- a/debian/patches/00002-Reproducible-build.patch     1970-01-01 
01:00:00.000000000 +0100
--- b/debian/patches/00002-Reproducible-build.patch     2021-03-02 
09:06:06.826207329 +0000
@@ -0,0 +1,28 @@
+Description: Make the build reproducible
+Author: Chris Lamb <la...@debian.org>
+Last-Update: 2021-03-02
+
+--- python-scrapy-2.4.1.orig/docs/conf.py
++++ python-scrapy-2.4.1/docs/conf.py
+@@ -9,7 +9,9 @@
+ # All configuration values have a default; values that are commented out
+ # serve to show the default.
+ 
++import os
+ import sys
++import time
+ from datetime import datetime
+ from os import path
+ 
+@@ -49,7 +51,10 @@ master_doc = 'index'
+ 
+ # General information about the project.
+ project = 'Scrapy'
+-copyright = f'2008\u2013{datetime.now().year}, Scrapy developers'
++build_date = datetime.utcfromtimestamp(
++    int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
++)
++copyright = f'2008\u2013{build_date.year}, Scrapy developers'
+ 
+ # The version info for the project you're documenting, acts as replacement for
+ # |version| and |release|, also used in various other places throughout the
--- a/debian/patches/00002-Reproducible-build.patch~    1970-01-01 
01:00:00.000000000 +0100
--- b/debian/patches/00002-Reproducible-build.patch~    2021-03-02 
09:05:49.602003318 +0000
@@ -0,0 +1,28 @@
+Description: Make the build reproducible
+Author: Chris Lamb <la...@debian.org>
+Last-Update: 2021-03-02
+
+--- python-scrapy-2.4.1.orig/docs/conf.py
++++ python-scrapy-2.4.1/docs/conf.py
+@@ -9,7 +9,9 @@
+ # All configuration values have a default; values that are commented out
+ # serve to show the default.
+ 
++import os
+ import sys
++import time
+ from datetime import datetime
+ from os import path
+ 
+@@ -49,7 +51,10 @@ master_doc = 'index'
+ 
+ # General information about the project.
+ project = 'Scrapy'
+-copyright = f'2008\u2013{datetime.now().year}, Scrapy developers'
++year = datetime.utcfromtimestamp(
++    int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
++).year
++copyright = f'2008\u2013{year}, Scrapy developers'
+ 
+ # The version info for the project you're documenting, acts as replacement for
+ # |version| and |release|, also used in various other places throughout the
--- a/debian/patches/series     2021-03-02 08:55:59.355009205 +0000
--- b/debian/patches/series     2021-03-02 09:05:31.529789277 +0000
@@ -1 +1,2 @@
 0001-Disable-hoverxref-and-notfound-Sphinx-extensions.patch
+00002-Reproducible-build.patch
--- a/docs/conf.py      2021-03-02 08:55:59.355009205 +0000
--- b/docs/conf.py      2021-03-02 09:06:05.762194727 +0000
@@ -9,7 +9,9 @@
 # All configuration values have a default; values that are commented out
 # serve to show the default.
 
+import os
 import sys
+import time
 from datetime import datetime
 from os import path
 
@@ -49,7 +51,10 @@
 
 # General information about the project.
 project = 'Scrapy'
-copyright = f'2008\u2013{datetime.now().year}, Scrapy developers'
+build_date = datetime.utcfromtimestamp(
+    int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
+)
+copyright = f'2008\u2013{build_date.year}, Scrapy developers'
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the

Reply via email to