[Reproducible-builds] Bug#824266: mkdocs: Please support SOURCE_DATE_EPOCH specification for build time stamps [origin: bam at debian.org]

Mattia Rizzolo mattia at debian.org
Fri May 20 21:09:14 UTC 2016


On Fri, May 20, 2016 at 10:47:37PM +0200, Reiner Herrmann wrote:
> I'm not a Python expert, but the example looks right to me:
> 
> $ export SOURCE_DATE_EPOCH=1234567890
> 
> $ date -u -d @$SOURCE_DATE_EPOCH
> Fri Feb 13 23:31:30 UTC 2009
> 
> $ python
> >>> import os, time, datetime
> >>> datetime.datetime.utcfromtimestamp(int(os.environ.get('SOURCE_DATE_EPOCH', time.gmtime())))
> datetime.datetime(2009, 2, 13, 23, 31, 30)

The problem lies in the fallback case, where SDE is not defined.  It
calls `time.gmtime()` (that's the fallback of the os.environ.get()).  If
you try unsetting SDE this will happen:

TypeError: int() argument must be a string, a bytes-like object or a number, not 'time.struct_time'

I replied to the bug, as IMHO it's not that hard to get the current
epoch, it's just `time.time()` (maybe wrapped in int()):

In [21]: time.gmtime()
Out[21]: time.struct_time(tm_year=2016, tm_mon=5, tm_mday=20, tm_hour=21, tm_min=8, tm_sec=42, tm_wday=4, tm_yday=141, tm_isdst=0)

In [22]: time.time()
Out[22]: 1463778524.5374782

In [23]: int(time.time())
Out[23]: 1463778526

-- 
regards,
                        Mattia Rizzolo

GPG Key: 66AE 2B4A FCCF 3F52 DA18  4D18 4B04 3FCD B944 4540      .''`.
more about me:  https://mapreri.org                             : :'  :
Launchpad user: https://launchpad.net/~mapreri                  `. `'`
Debian QA page: https://qa.debian.org/developer.php?login=mattia  `-
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/reproducible-builds/attachments/20160520/cd4db884/attachment.sig>


More information about the Reproducible-builds mailing list