Commit 7a0698d1 by Alois Klink

Set mtime on setup.py/PKG-INFO when building sdist

Previously, the mtime was the default value of 0.

Fixes #670.

This stops the following warning when using gnu tar:
implausibly old time stamp 1970-01-01 01:00:00
parent b2189691
......@@ -2,6 +2,7 @@
import os
import re
import tarfile
import time
from collections import defaultdict
from copy import copy
......@@ -83,12 +84,14 @@ class SdistBuilder(Builder):
setup = self.build_setup()
tar_info = tarfile.TarInfo(pjoin(tar_dir, "setup.py"))
tar_info.size = len(setup)
tar_info.mtime = time.time()
tar.addfile(tar_info, BytesIO(setup))
pkg_info = self.build_pkg_info()
tar_info = tarfile.TarInfo(pjoin(tar_dir, "PKG-INFO"))
tar_info.size = len(pkg_info)
tar_info.mtime = time.time()
tar.addfile(tar_info, BytesIO(pkg_info))
finally:
tar.close()
......
......@@ -408,6 +408,9 @@ def test_default_with_excluded_data(mocker):
assert "my-package-1.2.3/pyproject.toml" in names
assert "my-package-1.2.3/setup.py" in names
assert "my-package-1.2.3/PKG-INFO" in names
# all last modified times should be set to a valid timestamp
for tarinfo in tar.getmembers():
assert 0 < tarinfo.mtime
def test_proper_python_requires_if_two_digits_precision_version_specified():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment