|
| 1 | +# Pyodide Updates |
| 2 | + |
| 3 | +This document describes what is needed to update [Pyodide](https://pyodide.org/en/stable/project/changelog.html) to its latest version. |
| 4 | + |
| 5 | +### Requirements |
| 6 | + |
| 7 | +* a terminal compatible with *Bash* commands. |
| 8 | +* *Node.js* (stable or latest) to run `npm` commands. |
| 9 | +* a *Python* environment. |
| 10 | +* an [npm account](https://www.npmjs.com/) to publish the updated package. This account must belong to a maintainer or developer who is allowed to publish the package on *npm*. |
| 11 | +* a network connection to fetch data from various sources. |
| 12 | + |
| 13 | +The *minimal Python environment* can be created via the following commands: |
| 14 | + |
| 15 | +```sh |
| 16 | +python3 -m venv env |
| 17 | +source env/bin/activate |
| 18 | +pip3 install --upgrade pip |
| 19 | +pip3 install --ignore-requires-python python-minifier |
| 20 | +pip3 install setuptools |
| 21 | +``` |
| 22 | + |
| 23 | +## How to build |
| 24 | + |
| 25 | + * checkout a new branch via `git checkout -b pyodide-X.Y.Z` where `X.Y.Z` is the version that should be updated |
| 26 | + * create the *Python* environment which is needed to create and optimize both JS and Python files |
| 27 | + * run `npm ci` to be sure all `package-lock.json` dependencies are present/installed |
| 28 | + * run `npm run update:pyodide` to: |
| 29 | + * write the latest published version into `versions/pyodide` |
| 30 | + * update dependent files and source maps to reflect such version |
| 31 | + * build the latest `dist/` version of the package |
| 32 | + * run all tests (you might also need to run `playwright install chromium` if tests don't run) |
| 33 | + * once all tests are green, be sure you also run `npm run build:graph`, which: |
| 34 | + * fetches the list of versions from the *Pyodide* documentation page |
| 35 | + * adds versions not already known in `rollup/pyodide_graph.json` |
| 36 | + * updates compatible modules to their own latest version too |
| 37 | + |
| 38 | +The graph is then used, after this module is published, via https://packages.pyscript.net/, so it's important that this file is updated too whenever a new version of Pyodide is published. |
| 39 | + |
| 40 | +At this point, feel free to commit with a meaningful message: |
| 41 | + |
| 42 | +```sh |
| 43 | +# add all changed files |
| 44 | +git add . |
| 45 | +# create a meaningful commit |
| 46 | +git commit -m 'Updated Pyodide to version X.Y.Z' |
| 47 | +# push the branch and follow the instructions to create the MR |
| 48 | +git push |
| 49 | +``` |
| 50 | + |
| 51 | +Usually in the *MR* it's convenient to point to the Pyodide changelog, as a *Pyodide*-only release means nothing else changed in *PyScript* itself. |
| 52 | + |
| 53 | +Once the *MR* is approved and merged into `main`, run `git checkout main` and `git pull --rebase origin main` to update the local `main` branch with the latest changes. |
| 54 | + |
| 55 | +## How to publish on npm |
| 56 | + |
| 57 | +Because the only change here would be *Pyodide*, and unless such an update requires changes elsewhere, the *semver* convention is to increase the **patch** number. |
| 58 | + |
| 59 | +```sh |
| 60 | +npm version patch |
| 61 | +``` |
| 62 | + |
| 63 | +This command increases the patch by one, modifying `package.json` automatically, and it creates a tag. |
| 64 | + |
| 65 | +To be sure everything is fine, `npm run build` should not create different artifacts. If it does, it means that some artifact was missing from the previous branch, and that's OK, but we need all artifacts to land on *npm*. |
| 66 | + |
| 67 | +The same is true for `npm run build:graph` but again, if some new artifact is created, please add it. |
| 68 | + |
| 69 | +At this point both the changes and the tag need to be pushed to the remote: |
| 70 | + |
| 71 | +```sh |
| 72 | +git add . |
| 73 | +git commit -m 'updated package version' |
| 74 | +git push |
| 75 | +# push the tag too |
| 76 | +git push --tags |
| 77 | +# publish to npm - it asks for 2FA / OTP directly |
| 78 | +# replace 42 with your one-time password (OTP) |
| 79 | +npm publish --otp=42 |
| 80 | +``` |
| 81 | + |
| 82 | +Once the new version of `polyscript` lands on *npm*, it is possible to move forward with a new [PyScript Release](https://github.com/pyscript/docs/blob/main/docs/developers.md#release-pyscript). |
0 commit comments