Skip to content

Commit bc3465f

Browse files
committed
avoid checking SOURCES.txt in sdist
1 parent 9909527 commit bc3465f

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

tests/test_pkg.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
"""Check the content of source code and source distribution.
1+
"""Check the content of source code and test build source distribution.
22
33
Binary distribution (wheel) is checked in test workflow.
44
"""
55

66
from __future__ import annotations
77

88
import subprocess
9-
import tarfile
109
from glob import glob
1110
from pathlib import Path
1211
from typing import TYPE_CHECKING
@@ -21,33 +20,18 @@
2120

2221
class TestCheckDistribution:
2322
def test_source_code(self):
24-
"""Directly check the source code in the working directory."""
23+
"""Check the source code in the working directory."""
2524
src_txt_path = PROJECT_ROOT / "src/pymatgen.egg-info/SOURCES.txt"
2625

2726
_check_src_txt_is_complete(PROJECT_ROOT, src_txt_path)
2827

29-
def test_source_distribution(self):
30-
"""Build the source distribution and verify its contents."""
31-
28+
def test_build_source_distribution(self):
29+
"""Test build the source distribution (sdist)."""
3230
with ScratchDir("."):
3331
# Build the source distribution
3432
subprocess.run(["python", "-m", "pip", "install", "--upgrade", "build"], check=True)
3533
subprocess.run(["python", "-m", "build", "--sdist", PROJECT_ROOT, "--outdir", ".", "-C--quiet"], check=True)
3634

37-
# Decompress sdist
38-
sdist_file = next(Path(".").glob("*.tar.gz"))
39-
sdist_dir = sdist_file.name.removesuffix(".tar.gz")
40-
with tarfile.open(sdist_file, "r:gz") as tar:
41-
# TODO: remove attr check after only 3.12+
42-
if hasattr(tarfile, "data_filter"):
43-
tar.extractall("", filter="data")
44-
else:
45-
tar.extractall("") # noqa: S202
46-
47-
# Verify source distribution contents
48-
src_txt_path = f"{sdist_dir}/src/pymatgen.egg-info/SOURCES.txt"
49-
_check_src_txt_is_complete(project_root=sdist_dir, src_txt_path=src_txt_path)
50-
5135

5236
def _check_src_txt_is_complete(project_root: PathLike, src_txt_path: PathLike) -> None:
5337
"""Check that all source code and data files are listed in given SOURCES.txt.

0 commit comments

Comments
 (0)