From 58daea3686ba7658d51cba6e4bd1c1016b5b1a70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Wed, 27 Nov 2024 15:43:25 +0100 Subject: [PATCH] compat: Hatchling 1.26 (#7526) --- .github/workflows/build.yaml | 8 ++++++++ .github/workflows/gallery.yaml | 2 +- pyproject.toml | 3 ++- scripts/verify_build_size.py | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 scripts/verify_build_size.py diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 09b47c4e93..91753fa7d6 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -55,6 +55,8 @@ jobs: name: conda path: dist/*tar.bz2 if-no-files-found: error + - name: Verify size + run: python scripts/verify_build_size.py conda conda_publish: name: Publish Conda @@ -106,6 +108,10 @@ jobs: name: pip path: dist/ if-no-files-found: error + - name: Verify sizes + run: | + python scripts/verify_build_size.py sdist + python scripts/verify_build_size.py whl pip_install: name: Install PyPI @@ -165,6 +171,8 @@ jobs: name: npm if-no-files-found: error path: ./${{ env.PACKAGE }}/${{ env.TARBALL }} + - name: Verify size + run: python scripts/verify_build_size.py npm npm_publish: name: Publish NPM diff --git a/.github/workflows/gallery.yaml b/.github/workflows/gallery.yaml index cc74ad3acd..761cc05733 100644 --- a/.github/workflows/gallery.yaml +++ b/.github/workflows/gallery.yaml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest defaults: run: - shell: bash -e {0} + shell: bash -el {0} steps: - name: Checkout uses: actions/checkout@v3 diff --git a/pyproject.toml b/pyproject.toml index e2d58865aa..b7b34d79c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -111,6 +111,7 @@ raw-options = { version_scheme = "no-guess-dev" } [tool.hatch.build.targets.wheel] include = ["panel"] +exclude = ["panel/node_modules"] [tool.hatch.build.targets.wheel.force-include] "panel/dist" = "panel/dist" @@ -121,7 +122,7 @@ include = ["panel"] [tool.hatch.build.targets.sdist] include = ["panel", "scripts", "examples"] -exclude = ["scripts/jupyterlite"] +exclude = ["scripts/jupyterlite", "panel/node_modules"] [tool.hatch.build.targets.sdist.force-include] "panel/dist" = "panel/dist" diff --git a/scripts/verify_build_size.py b/scripts/verify_build_size.py new file mode 100644 index 0000000000..b71384d1c9 --- /dev/null +++ b/scripts/verify_build_size.py @@ -0,0 +1,32 @@ +import sys + +from pathlib import Path + +EXPECTED_SIZES_MB = { + "conda": 25, + "npm": 25, + "sdist": 30, + "whl": 30, +} + +GLOB_PATH = { + "conda": "dist/*.tar.bz2", + "npm": "panel/*.tgz", + "sdist": "dist/*.tar.gz", + "whl": "dist/*.whl", +} + +PATH = Path(__file__).parents[1] + + +def main(build): + files = list(PATH.rglob(GLOB_PATH[build])) + assert len(files) == 1, f"Expected one {build} file, got {len(files)}" + + size = files[0].stat().st_size / 1024**2 + assert size < EXPECTED_SIZES_MB[build], f"{build} file is too large: {size:.2f} MB" + print(f"{build} file size: {size:.2f} MB") + + +if __name__ == "__main__": + main(sys.argv[1])