python datetime .. grrr

Vagrant Cascadian vagrant at reproducible-builds.org
Sat Feb 11 23:01:57 UTC 2023


On 2023-02-11, Larry Doolittle wrote:
> verilator 5.006-2 in Debian is not reproducible
>   https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/verilator.html
> and I finally figured out why.  It's timezone handling in python3 datetime.
>
> $ cat verilator_doc.py
> # Distilled from upstream verilator docs/guide/conf.py
> # (post-commit 87a7881d46)
> from datetime import datetime
> import os
> try:
>     # https://reproducible-builds.org/specs/source-date-epoch/
>     doc_now = datetime.fromtimestamp(int(os.environ["SOURCE_DATE_EPOCH"]))
>     print("Using SOURCE_DATE_EPOCH")
> except Exception:
>     doc_now = datetime.now()
> # Date format to ISO
> today_fmt = doc_now.strftime("%F")
> print(today_fmt)
> $ cat repro 
> export SOURCE_DATE_EPOCH=$(date -d "07 Feb 2023 17:17:27 +0100" +%s)
> echo $SOURCE_DATE_EPOCH
> # https://tests.reproducible-builds.org/debian/index_variations.html
> TZ="/usr/share/zoneinfo/Etc/GMT+12" python3 verilator_doc.py
> TZ="/usr/share/zoneinfo/Etc/GMT-14" python3 verilator_doc.py
> $ sh repro
> 1675786647
> Using SOURCE_DATE_EPOCH
> 2023-02-07
> Using SOURCE_DATE_EPOCH
> 2023-02-08
>
> I've spent more than an hour RTFM and trying different ways to get
> python3 datetime to ignore the local timezone when computing dates.
> No joy.  Surely someone here has learned how to that?

There are some python examples that might be helpful:

  https://reproducible-builds.org/docs/source-date-epoch/

I would recommend linking to the documentation about source-date-epoch
rather than the spec itself that you linked to in your reproducer code,
as it has practical hands-on examples that would be a bit too much to
embed into the specification.

Would it also be possible to simply remove the date from the
documentation? Unless you actually patch the documentation between
versions in debian, using SOURCE_DATE_EPOCH for the publication date is
still somewhat of an abitrary date that might be more misleading than
accurate in many cases...

live well,
  vagrant
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 227 bytes
Desc: not available
URL: <http://lists.reproducible-builds.org/pipermail/rb-general/attachments/20230211/71d637f8/attachment.sig>


More information about the rb-general mailing list