Skip to content

Extend SOURCE_DATE_EPOCH support - #2503

Merged
tk0miya merged 6 commits into
stablefrom
unknown repository
May 5, 2016
Merged

tk0miya merged 6 commits into
stablefrom
unknown repository

Conversation

@ghost

@ghost ghost commented Apr 28, 2016

Copy link
Copy Markdown

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.

Comment thread sphinx/config.py Outdated
# 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
Copy Markdown
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

ghost commented May 2, 2016

Copy link
Copy Markdown
Author

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

@mitya57

mitya57 commented May 2, 2016 •

Copy link
Copy Markdown
Contributor

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

ghost commented May 3, 2016

Copy link
Copy Markdown
Author

@mitya57 : oh yes, that was missing!

@tk0miya

tk0miya commented May 3, 2016

Copy link
Copy Markdown
Member

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

@ghost

ghost commented May 3, 2016

Copy link
Copy Markdown
Author

Thanks for your support!

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

tk0miya commented May 5, 2016

Copy link
Copy Markdown
Member

Merged!
Thank you for contribution!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants