|
1 |
| -"""Check the content of source code and source distribution. |
| 1 | +"""Check the content of source code and test build source distribution. |
2 | 2 |
|
3 | 3 | Binary distribution (wheel) is checked in test workflow.
|
4 | 4 | """
|
5 | 5 |
|
6 | 6 | from __future__ import annotations
|
7 | 7 |
|
8 | 8 | import subprocess
|
9 |
| -import tarfile |
10 | 9 | from glob import glob
|
11 | 10 | from pathlib import Path
|
12 | 11 | from typing import TYPE_CHECKING
|
|
21 | 20 |
|
22 | 21 | class TestCheckDistribution:
|
23 | 22 | def test_source_code(self):
|
24 |
| - """Directly check the source code in the working directory.""" |
| 23 | + """Check the source code in the working directory.""" |
25 | 24 | src_txt_path = PROJECT_ROOT / "src/pymatgen.egg-info/SOURCES.txt"
|
26 | 25 |
|
27 | 26 | _check_src_txt_is_complete(PROJECT_ROOT, src_txt_path)
|
28 | 27 |
|
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).""" |
32 | 30 | with ScratchDir("."):
|
33 | 31 | # Build the source distribution
|
34 | 32 | subprocess.run(["python", "-m", "pip", "install", "--upgrade", "build"], check=True)
|
35 | 33 | subprocess.run(["python", "-m", "build", "--sdist", PROJECT_ROOT, "--outdir", ".", "-C--quiet"], check=True)
|
36 | 34 |
|
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 |
| - |
51 | 35 |
|
52 | 36 | def _check_src_txt_is_complete(project_root: PathLike, src_txt_path: PathLike) -> None:
|
53 | 37 | """Check that all source code and data files are listed in given SOURCES.txt.
|
|
0 commit comments