Skip to content

Publishing

Follow these instructions for releasing a new version of Mesop publicly via PyPI (e.g. pip install mesop).

If you haven't done this before, follow the first-time setup.

Update version to RC

Update mesop/version.py by incrementing the version number. We follow semver.

You want to first create an RC (release candidate) to ensure that it works.

For example, if the current version is: 0.7.0, then you should increment the version to 0.8.0rc0 which will create an RC, which is treated as a pre-release by PyPI.

Install locally

From the workspace root, run the following command:

source ./scripts/pip.sh

This will build the Mesop pip package and install it locally so you can test it.

Testing locally

TIP: Double check the Mesop version is expected. It's easy to use the wrong version of Mesop by loading mesop or gunicorn from a different Python path (i.e. not the venv you just created).

Dev CLI

The above shell script will run the following command:

mesop main.py

This will start the Mesop dev server and you can test that hot reload works.

Gunicorn integration

gunicorn main:me

Note: gunicorn should already be installed by the shell script above.

Upload to PyPI

If the testing above looks good, then continue with uploading to PyPI.

rm -rf /tmp/mesoprelease-test/venv-twine \
&& virtualenv --python python3 /tmp/mesoprelease-test/venv-twine \
&& source /tmp/mesoprelease-test/venv-twine/bin/activate \
&& pip install --upgrade pip \
&& pip install twine \
&& cd /tmp/mesoprelease-test \
&& twine upload mesop*.whl

Visit https://pypi.org/project/mesop/ to see that the new version has been published.

Test on Colab

Because Colab installs from PyPI, you will need to test the RC on Colab after uploading to PyPI.

Open our Mesop Colab notebook. You will need to explicitly pip install the RC version as pip will not automatically install a pre-release version, even if it's the newest version. So change the first cell to something like:

 !pip install mesop==0.X.Yrc0

Tip: sometimes it takes a minute for the PyPI registry to be updated after upload, so just try again.

Then, run all the cells and make sure it works. Usually if something breaks in Colab, it's pretty obvious because the output isn't displayed, etc.

Change the version from RC to regular release

If you find an issue, then redo the above steps and create another RC candidate: 0.8.0rc0 -> 0.8.0rc1.

If all the testing looks good, then you can update mesop/version.py and change the version from RC to a regular release, for example:

0.8.0rc0 -> 0.8.0

Re-do the steps above to build, test and upload it to PyPI.

Publish GitHub release

After you've uploaded a new regular release to PyPI, submit the PR which bumps the version and then publish a GitHub release.

  1. Click "Choose a tag" and type in the version you just released. This will create a new Git tag.
  2. Click "Genereate release notes".
  3. Click "Create a discussion for this release".
  4. Click "Publish release".

First-time upload setup

Create a file ~/.pypirc:

[pypi]
  username = __token__
  password = {{password}}

You will need to get a PyPI token generated by one of the project maintainers.