diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 64b23a9d..6283d2aa 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -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 diff --git a/.gitignore b/.gitignore index 5522b620..016b9252 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /.cache /dist /static/pyodide +/files/requirements.txt /.jupyterlite.doit.db __pycache__/ diff --git a/tools/requirements.py b/tools/requirements.py new file mode 100644 index 00000000..0f10dcb8 --- /dev/null +++ b/tools/requirements.py @@ -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")