pyscript-cli icon indicating copy to clipboard operation
pyscript-cli copied to clipboard

Adding a command to convert a project for use offline

Open bkiu opened this issue 1 year ago • 0 comments

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:

  • pyscript files from pyscript.net
  • pyodide files from Github
  • micropython files from cdn.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.

bkiu avatar May 21 '24 20:05 bkiu