-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
bpo-38632: respect SOURCE_DATE_EPOCH when building .tar sdists #20331
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -306,6 +306,24 @@ def test_make_archive_tar(self): | |
| self.assertEqual(os.path.basename(res), 'archive.tar') | ||
| self.assertEqual(self._tarinfo(res), self._created_files) | ||
|
|
||
| def test_make_archive_tar_source_date_epoch(self): | ||
| ORIGINAL_SDE = os.environ.get('SOURCE_DATE_EPOCH') | ||
| try: | ||
| os.environ['SOURCE_DATE_EPOCH'] = '1337' | ||
| base_dir = self._create_files() | ||
| base_name = os.path.join(self.mkdtemp() , 'archive') | ||
| res = make_archive(base_name, 'tar', base_dir, 'dist') | ||
|
|
||
| archive = tarfile.open(res,mode='r') | ||
| for item in archive: | ||
| self.assertLessEqual(item.mtime, 1337) | ||
| finally: | ||
| archive.close() | ||
| if ORIGINAL_SDE is None: | ||
| del os.environ['SOURCE_DATE_EPOCH'] | ||
| else: | ||
| os.environ['SOURCE_DATE_EPOCH'] = ORIGINAL_SDE | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could make all this setup/teardown simpler by using one of the helpers in |
||
|
|
||
| @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run') | ||
| def test_make_archive_gztar(self): | ||
| base_dir = self._create_files() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| Partial support for ``SOURCE_DATE_EPOCH`` environment variable for sdists | ||
| has been added in distutils. When the ``SOURCE_DATE_EPOCH`` environment | ||
| variable is set, the ``mtime`` of the files in an sdist tar archive will not | ||
| be later than ``SOURCE_DATE_EPOCH``. This is a firs step to simplify getting | ||
| byte identical reproducibility of source dists. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There a bunch of other things that add variability to the end artifact. For example ZIP using current datetime in the header, which also needs to be fixed, making sure directory/files are traveres in the same order... etc. I try to keep things minimal as PRs here tends to sits for years, and the bigger the longer.
Yes, it extends and call it, so if the result of this is not reproducible then it needs to be monkeypatch in setuptools (see pypa/setuptools#2136 which I need to finish) Basically 1/2 of the upstream patch is copy-pasting code from distutils to tweak the internal behavior.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That sounds OK then! |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.