Skip to content

Commit

Permalink
Add the clean-dist tool script
Browse files Browse the repository at this point in the history
  • Loading branch information
juntyr committed Feb 12, 2025
1 parent 1325a52 commit f1f39c9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
mkdir -p static
mv pyodide/dist static/pyodide
rm -rf static/pyodide/*-tests.tar
rm -f static/pyodide/tsconfig.tsbuildinfo
python tools/clean-dist.py static/pyodide
jupyter lite build --output-dir staging
cp static/favicons/favicon.ico staging/
find staging/ -name favicon.ico | xargs -L1 cp -f static/favicons/favicon.ico
Expand Down
32 changes: 32 additions & 0 deletions tools/clean-dist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import argparse
import json
from pathlib import Path

parser = argparse.ArgumentParser()
parser.add_argument("dist_path")
args = parser.parse_args()

dist_path = Path(args.dist_path)
lock_path = dist_path / "pyodide-lock.json"

with lock_path.open("r") as f:
lock = json.load(f)

packages_to_delete = []

for name, package in lock["packages"].items():
if package["unvendored_tests"] is not True:
continue

filename = lock["packages"][f"{name}-tests"]["file_name"]
print(f"Removed {filename}")
(dist_path / filename).unlink()

packages_to_delete.append(f"{name}-tests")
package["unvendored_tests"] = False

for name in packages_to_delete:
del lock["packages"][name]

with lock_path.open("w") as f:
json.dump(lock, f)
2 changes: 1 addition & 1 deletion tools/pypa-simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
shutil.rmtree(pypa_path)
pypa_path.mkdir(parents=True, exist_ok=True)

with lock_path.open("rb") as f:
with lock_path.open("r") as f:
lock = json.load(f)

packages = dict()
Expand Down
2 changes: 1 addition & 1 deletion tools/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Package:
is_pure: bool


with lock_path.open("rb") as f:
with lock_path.open("r") as f:
lock = json.load(f)

python = lock["info"]["python"]
Expand Down

0 comments on commit f1f39c9

Please sign in to comment.