Skip to content

Commit

Permalink
compat: Hatchling 1.26 (#7526)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Nov 27, 2024
1 parent c6ac0a8 commit 58daea3
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gallery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
32 changes: 32 additions & 0 deletions scripts/verify_build_size.py
Original file line number Diff line number Diff line change
@@ -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])

0 comments on commit 58daea3

Please sign in to comment.