Skip to content

Commit

Permalink
Add simple requirements.txt file
Browse files Browse the repository at this point in the history
  • Loading branch information
juntyr committed Oct 25, 2024
1 parent 1fd47e7 commit 7cca76e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ jobs:
--non-interactive \
PYODIDE_PACKAGES="aiohttp,basemap,cdsapi,cfgrib,cf-units,cmcrameri,dask,earthkit,ecmwf-api-client,ecmwf-opendata,field-compression-benchmark,fsspec,git2,gribscan,h5netcdf,intake,ipyfilite,ipython,kerchunk,lzma,matplotlib,MetPy,netcdf4,numcodecs,numpy,pandas,pint,proplot,requests,scipy,sympy,s3fs,xarray,xeofs,zarr" \
make
- name: Extract the requirements.txt file
run: python3 tools/requirements.txt
- name: Clean up the pyodide build
run: |
cd pyodide
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/.cache
/dist
/static/pyodide
/files/requirements.txt
/.jupyterlite.doit.db

__pycache__/
55 changes: 55 additions & 0 deletions tools/requirements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import json
from pathlib import Path

lock_path = Path("pyodide") / "dist" / "pyodide-lock.json"
requirements_path = Path("files") / "requirements.txt"

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

python = lock["info"]["python"]
pyodide = lock["info"]["version"]

packages = dict()

IGNORE_PACKAGES = []

for package in lock["packages"].values():
if package["package_type"] != "package":
continue
if Path(package["file_name"]).suffix != ".whl":
continue
if package["install_dir"] != "site":
continue

if package["name"] in IGNORE_PACKAGES:
continue

packages[package["name"]] = package["version"]

with requirements_path.open("w") as f:
f.write(
"# "
+ " Online Laboratory for Climate Science and Meteorology ".center(76, "=")
+ " #\n"
)
f.write("# " + " requirements.txt (automatically generated) ".center(76) + " #\n")
f.write("# " + "".center(76) + " #\n")
f.write(
"# "
+ " Please note that this list is currently only an approximation ".center(76)
+ " #\n"
)
f.write(
"# "
+ " and does not include e.g. shared library dependencies ".center(76)
+ " #\n"
)
f.write("# " + "".center(76, "=") + " #\n")
f.write("\n")
f.write(f"# python == {python}\n")
f.write(f"# pyodide == {pyodide}\n")
f.write("\n")

for name, version in sorted(packages.items()):
f.write(f"{name} == {version}\n")

0 comments on commit 7cca76e

Please sign in to comment.