[Git][reproducible-builds/reproducible-website][master] Document S_D_E for python zip creation

Bernhard M. Wiedemann (@bmwiedemann-guest) gitlab at salsa.debian.org
Thu Jul 18 12:23:42 UTC 2024



Bernhard M. Wiedemann pushed to branch master at Reproducible Builds / reproducible-website


Commits:
7678a3e8 by Bernhard M. Wiedemann at 2024-07-18T14:23:12+02:00
Document S_D_E for python zip creation

- - - - -


1 changed file:

- _docs/source-date-epoch.md


Changes:

=====================================
_docs/source-date-epoch.md
=====================================
@@ -36,6 +36,18 @@ date_str = time.strftime(
 )
 ```
 
+for zip files:
+
+```python
+import os
+import time
+import zipfile
+filetime = max(315532800, int(os.environ.get('SOURCE_DATE_EPOCH', time.time())))
+with zipfile.ZipFile("test.zip", 'w') as ziparchive:
+    file_zipinfo = zipfile.ZipInfo("hello.txt", date_time=time.gmtime(filetime))
+    ziparchive.writestr(file_zipinfo, "Hello world\n")
+```
+
 ### Python >= 2.x
 
 If you still require Python 2.x support, you will need to use the non-recommended [`datetime.utcfromtimestamp`](https://docs.python.org/3.8/library/datetime.html#datetime.datetime.utcfromtimestamp) method ([more info](https://blog.ganssle.io/articles/2019/11/utcnow.html)):



View it on GitLab: https://salsa.debian.org/reproducible-builds/reproducible-website/-/commit/7678a3e8d8685ec57451a3141daf235000a5d6d1

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://salsa.debian.org/reproducible-builds/reproducible-website/-/commit/7678a3e8d8685ec57451a3141daf235000a5d6d1
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20240718/0a165c80/attachment.htm>


More information about the rb-commits mailing list