Adding a command to convert a project for use offline
This is a command to convert an existing pyscript project for use offline. It depends on https://github.com/pyscript/pyscript/pull/2077 to pull the correct files via a tarball of built files.
The project path is passed through the first and only required argument,
It downloads the following resources:
-
pyscriptfiles frompyscript.net -
pyodidefiles from Github -
micropythonfiles fromcdn.jsdelivr.net
The option is available to download the entire pyodide library via the download-full-pyodide flag.
All relevant HTML files are also updated to point to the local /pyscript/ directory instead of https://pyscript.net....
Since there's not an easy way to retrieve all the active configuration files in use, config-files is a comma-separated list of files to be passed in. The script then loops through those files and updates the interpreter to the local one based on what is passed through the --interpreter option (defaults to pyodide, which may or may not be a good idea).
Finally, it also warns the user if any <py-config> or <mypy-config> tags are found, as it doesn't update the interpreter in those tags.
Written at PyCon US 2024 sprints.