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

Extend SOURCE_DATE_EPOCH support #2503

Merged
merged 6 commits into from May 5, 2016
Merged

Extend SOURCE_DATE_EPOCH support #2503

merged 6 commits into from May 5, 2016

Conversation

ghost
Copy link

@ghost ghost commented Apr 28, 2016

The SOURCE_DATE_EPOCH support is very important for reproducible builds of packages that use sphinx for their documentation.

  1. This patch extends this support to gettext
  2. A lot of users use a configuration like
    copyright = u'2006-%s, Author' % time.strftime('%Y')
    This breaks reproducibility, with an artificial copyright date related to build time instead of source date. I suggest to use SOURCE_DATE_EPOCH (when set) to correct these dates automatically.
  3. In sphinx/util/i18n.py, the date = gmtime(float(source_date_epoch)) definition leads to an error when passed to babel.dates.format_date, that needs a date or datetime object (maybe my setup? I use babel 1.3), so I replaced it with an equivalent datetime call.

# correct values of copyright year that are not coherent with
# the SOURCE_DATE_EPOCH environment variable:
if getenv('SOURCE_DATE_EPOCH') is not None:
for k in ['copyright','epub_copyright']:
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nit: you can use tuple instead of a list here.

@tk0miya tk0miya added this to the 1.4.2 milestone May 1, 2016
* use tuple instead of list
* compile regex to find copyright year
* enclose test inside try/finally
@ghost
Copy link
Author

ghost commented May 2, 2016

@mitya57, @tk0miya : thanks for your remarks that enhance this little piece of code.

@mitya57
Copy link
Contributor

mitya57 commented May 2, 2016

PEP-8-ifying the files won't hurt, but in general looks fine. 👍

Oh, and maybe you can include a link to https://reproducible-builds.org/specs/source-date-epoch/ in the comments somewhere?

@ghost
Copy link
Author

ghost commented May 3, 2016

@mitya57 : oh yes, that was missing!

@tk0miya
Copy link
Member

tk0miya commented May 3, 2016

LGTM! I will merge this within a day if no objection :-)

@ghost
Copy link
Author

ghost commented May 3, 2016

Thanks for your support!

@tk0miya tk0miya merged commit 20719f0 into sphinx-doc:stable May 5, 2016
@tk0miya
Copy link
Member

tk0miya commented May 5, 2016

Merged!
Thank you for contribution!

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.

2 participants