Skip to content

Commit

Permalink
Use tarfile filter in Python 3.12+
Browse files Browse the repository at this point in the history
Closes #48.
  • Loading branch information
jwodder committed Sep 22, 2023
1 parent 5bb7297 commit 291f583
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ v2.3.0 (in development)
- Raise a `ConfigError` if the selected `tool.versioningit.format` field is not
a string
- Update tests for pydantic 2.0
- Update tests for Python 3.12

v2.2.0 (2023-02-11)
-------------------
Expand Down
18 changes: 14 additions & 4 deletions test/test_end2end.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,16 @@ def test_build_from_sdist(tmp_path: Path) -> None:
# This test is used to check that building from an sdist succeeds even when
# a VCS is not installed, though it passes when one is installed as well.
srcdir = tmp_path / "src"
shutil.unpack_archive(
str(DATA_DIR / "mypackage-0.1.0.post4+g56ed573.tar.gz"), str(srcdir)
)
if sys.version_info >= (3, 12):
shutil.unpack_archive(
str(DATA_DIR / "mypackage-0.1.0.post4+g56ed573.tar.gz"),
str(srcdir),
filter="data",
)
else:
shutil.unpack_archive(
str(DATA_DIR / "mypackage-0.1.0.post4+g56ed573.tar.gz"), str(srcdir)
)
(srcsubdir,) = srcdir.iterdir()
init_path = Path("src", "mypackage", "__init__.py")
init_src = (srcsubdir / init_path).read_text()
Expand Down Expand Up @@ -406,7 +413,10 @@ def get_repo_status(repodir: Path) -> str:

def unpack_sdist(dist_dir: Path, tmp_path: Path) -> Path:
(sdist,) = dist_dir.glob("*.tar.gz")
shutil.unpack_archive(str(sdist), str(tmp_path / "sdist"))
if sys.version_info >= (3, 12):
shutil.unpack_archive(str(sdist), str(tmp_path / "sdist"), filter="data")
else:
shutil.unpack_archive(str(sdist), str(tmp_path / "sdist"))
(sdist_src,) = (tmp_path / "sdist").iterdir()
return sdist_src

Expand Down

0 comments on commit 291f583

Please sign in to comment.