Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the build reproducible #5019

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lamby
Copy link

@lamby lamby commented Mar 2, 2021

Whilst working on the Reproducible Builds effort I noticed that scrapy could not be built reproducibly

This is due to the documentation embedding the current build year in the generated files, therefore making the build vary depending on when you build it. The fix is to use SOURCE_DATE_EPOCH if it is exported to the surrounding environment.

I originally filed this in Debian as bug #983852.

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

This is due to the documentation embedding the current build year
in the generated files, therefore making the build vary depending
on when you build it. The fix is to use SOURCE_DATE_EPOCH [1] if
it is exported to the surrounding environmnent.

I originally filed this in Debian as bug #983852 [2].

 [0] https://reproducible-builds.org/
 [1] https://reproducible-builds.org/specs/source-date-epoch/
 [2] https://bugs.debian.org/983852
@bmwiedemann
Copy link

bmwiedemann commented Mar 12, 2021

Auto-updating copyright at build time is a bad practice anyway, because building today's software next year, would produce copyright 2008–2022, Scrapy developers without any developer doing anything in 2022.

so the better fix could be to state copyright 2008 or copyright 2008-2021

@Gallaecio
Copy link
Member

I agree that it’s a bad practice, only better than not updating it at all.

The best I can think of at the moment is to go for a pre-commit hook that updates the year if it is out of date. But then you need to get contributors to install pre-commit.

Alternatively, we could use c4urself/bump2version#133 once implemented to make sure we update the year before every release.

docs/conf.py Outdated Show resolved Hide resolved
docs/conf.py Outdated Show resolved Hide resolved
@Gallaecio
Copy link
Member

Closing and reopening to re-run the tests with the latest changes from master

@Gallaecio Gallaecio closed this Mar 20, 2021
@Gallaecio Gallaecio reopened this Mar 20, 2021
@codecov
Copy link

codecov bot commented Mar 20, 2021

Codecov Report

Merging #5019 (c74703c) into master (f95ebd8) will decrease coverage by 0.35%.
The diff coverage is 90.31%.

Current head c74703c differs from pull request most recent head 34ea7b8. Consider uploading reports for the commit 34ea7b8 to get more accurate results

@@            Coverage Diff             @@
##           master    #5019      +/-   ##
==========================================
- Coverage   88.01%   87.65%   -0.36%     
==========================================
  Files         158      162       +4     
  Lines        9726    10301     +575     
  Branches     1433     1501      +68     
==========================================
+ Hits         8560     9029     +469     
- Misses        911     1000      +89     
- Partials      255      272      +17     
Impacted Files Coverage Δ
scrapy/utils/log.py 89.24% <ø> (ø)
scrapy/pipelines/images.py 90.35% <80.00%> (-1.47%) ⬇️
scrapy/core/http2/protocol.py 83.41% <83.41%> (ø)
scrapy/core/downloader/contextfactory.py 87.03% <84.61%> (-2.97%) ⬇️
scrapy/core/http2/stream.py 91.37% <91.37%> (ø)
scrapy/core/downloader/handlers/http11.py 93.68% <95.00%> (+1.22%) ⬆️
scrapy/core/http2/agent.py 96.38% <96.38%> (ø)
scrapy/core/downloader/handlers/http2.py 100.00% <100.00%> (ø)
scrapy/selector/unified.py 100.00% <100.00%> (ø)
scrapy/signals.py 100.00% <100.00%> (ø)
... and 16 more

lamby and others added 2 commits March 20, 2021 16:16
Co-authored-by: Adrián Chaves <adrian@chaves.io>
build_date = datetime.utcfromtimestamp(
int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
)
copyright = f'2008–{build_date.year}, Scrapy developers'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
build_date = datetime.utcfromtimestamp(
int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
)
copyright = f'2008–{build_date.year}, Scrapy developers'
copyright = f'2008–2023, Scrapy developers'

... plus removing the datetime, os, and time imports from this configuration module.

(rationale: it's nice to automate where possible -- and authorship doesn't expire -- but copyright does, and figuring that out (and updating notices like this) usually benefits from human thought and discussion)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants