|
1 | 1 | """ |
2 | 2 | Script file to strip unwanted files from dist tarball |
3 | | -
|
4 | 3 | """ |
5 | 4 |
|
6 | 5 | import os |
7 | 6 | import shutil |
| 7 | +from pathlib import Path |
| 8 | + |
| 9 | + |
| 10 | +def main(): |
| 11 | + """ |
| 12 | + Strip the files we don't want in the tarball |
| 13 | + """ |
| 14 | + dist_root = os.environ.get("MESON_DIST_ROOT") |
| 15 | + |
| 16 | + # Files/Folders to strip from the *.tar.gz |
| 17 | + exclude = [ |
| 18 | + ".github", |
| 19 | + "docs", |
| 20 | + "tests", |
| 21 | + "changelog", |
| 22 | + "stubs", |
| 23 | + Path("scripts") / "add-locked-targets-to-pyproject-toml.py", |
| 24 | + Path("scripts") / "inject-srcs-into-meson-build.py", |
| 25 | + Path("scripts") / "propogate-pyproject-metadata.py", |
| 26 | + Path("scripts") / "test-install.py", |
| 27 | + Path("scripts") / "changelog-to-release-template.py", |
| 28 | + Path("scripts") / "print-conda-recipe-pins.py", |
| 29 | + # Keep this one |
| 30 | + # Path("scripts") / "strip-sdist.py", |
| 31 | + ".pre-commit-config.yaml", |
| 32 | + ".gitignore", |
| 33 | + ".readthedocs.yaml", |
| 34 | + "Makefile", |
| 35 | + "environment-docs-conda-base.yml", |
| 36 | + "mkdocs.yml", |
| 37 | + "uv.lock", |
| 38 | + "requirements-docs-locked.txt", |
| 39 | + "requirements-incl-optional-locked.txt", |
| 40 | + "requirements-locked.txt", |
| 41 | + "requirements-only-tests-locked.txt", |
| 42 | + "requirements-only-tests-min-locked.txt", |
| 43 | + "requirements-upstream-dev.txt", |
| 44 | + ".copier-answers.yml", |
| 45 | + ".fprettify.rc", |
| 46 | + ] |
| 47 | + |
| 48 | + # Strip |
| 49 | + for path in exclude: |
| 50 | + abs_path = os.path.join(dist_root, path) |
| 51 | + if not os.path.exists(abs_path): |
| 52 | + msg = f"File not found: {abs_path}" |
| 53 | + raise FileNotFoundError(msg) |
| 54 | + |
| 55 | + if os.path.isdir(abs_path): |
| 56 | + shutil.rmtree(abs_path) |
| 57 | + |
| 58 | + elif os.path.isfile(abs_path): |
| 59 | + os.remove(abs_path) |
| 60 | + |
8 | 61 |
|
9 | | -dist_root = os.environ.get("MESON_DIST_ROOT") |
10 | | - |
11 | | -# Files/Folders to strip from the *.tar.gz |
12 | | -exclude = [ |
13 | | - ".github", |
14 | | - "docs", |
15 | | - "tests", |
16 | | - "changelog", |
17 | | - "stubs", |
18 | | - "scripts", |
19 | | - ".pre-commit-config.yaml", |
20 | | - ".gitignore", |
21 | | - ".readthedocs.yaml", |
22 | | - "Makefile", |
23 | | - "environment-docs-conda-base.yml", |
24 | | - "mkdocs.yml", |
25 | | - "uv.lock", |
26 | | - "requirements-docs-locked.txt", |
27 | | - "requirements-incl-optional-locked.txt", |
28 | | - "requirements-locked.txt", |
29 | | - "requirements-only-tests-locked.txt", |
30 | | - "requirements-only-tests-min-locked.txt", |
31 | | - "requirements-upstream-dev.txt", |
32 | | - ".copier-answers.yml", |
33 | | - ".fprettify.rc", |
34 | | -] |
35 | | - |
36 | | -# Stripping |
37 | | -for path in exclude: |
38 | | - abs_path = os.path.join(dist_root, path) |
39 | | - if not os.path.exists(abs_path): |
40 | | - print(f"File not found: {abs_path}") |
41 | | - if os.path.isdir(abs_path): |
42 | | - shutil.rmtree(abs_path) |
43 | | - elif os.path.isfile(abs_path): |
44 | | - os.remove(abs_path) |
| 62 | +if __name__ == "__main__": |
| 63 | + main() |
0 commit comments