|
| 1 | +""" |
| 2 | +Script file to strip unwanted files from dist tarball |
| 3 | +""" |
| 4 | + |
| 5 | +import os |
| 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 | + |
| 61 | + |
| 62 | +if __name__ == "__main__": |
| 63 | + main() |
0 commit comments