Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

Release Lino to PyPI

Here we go for releasing a new version of Lino to the world. This usually involves several packages. We usually do such a series of releases when some production site needs an upgrade and hence the list of packages we release depends on what we need for that site.

Overview

  • We assume that you have configured your environment.

  • Check that you have a clean working copy of all projects maintained by the Synodalsoft team:

    $ pp git pull
    
  • Check that all test suites are passing and all doc trees are building:

    $ pp inv prep test clean -b bd
    
  • (Currently not used:) For every demo project that has a test_restore.py file in its test suite, run makemigdump and add the new version to the tested_versions in the test_restore.py file. See Migration tests for details.

  • Decide which packages to release. In each candidate package you can say git log to decide whether there were relevant changes since the last release to pypi.

  • Update the release notes and the changelog in the book.

  • For each package you want to release, read Release a package.

Release a package

Repositories with a pyproject.toml

  • If you do it for the first time:

    pip install build twine
    
  • See current version:

    hatch version
    
  • Increase micro, minor or major part of version number (“major” if year has changed since last version, “minor” if month has changed, otherwise “micro”). In case of doubt specify yourself a version number:

    hatch version micro # or minor or major
    
  • Install the new version in your virtualenv, remove existing dist files, build new ones & check them:

    rm dist/* ; python -m build; twine check dist/* ; pip install -e .
    
  • If everything went well, publish it:

    twine upload dist/*; git ci -am "release to pypi"; git push
    
  • To avoid typing the two last commands for each release, you may create a file release-to-pypi.sh in your path with this content:

    #!/bin/bash
    set -e
    git st
    rm -f dist/*
    python -m build
    twine check dist/*
    pip install -e .
    read -p "Okay to release to PyPI ? [Yn] " -n 1 -r
    echo    # (optional) move to a new line
    if [[ $REPLY =~ ^[Nn]$ ]]
    then
        [[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 # handle exits from shell or function but don't exit interactive shell
    fi
    twine upload dist/*
    git ci -am "release to pypi"
    git push
    

Repositories with a setup.py

  • Update the version in the setup_info.py file. See Date-based versioning for details.

  • Create a source tarball and then publish it to PyPI:

    $ inv sdist release -b
    
  • Commit and push the new version number:

    $ git ci -am "release to pypi" && git push
    

Configure your environment

Of course you need maintainer’s permission on PyPI for the repositories to which you want to write.

You also need to configure your ~/.pypirc file:

[distutils]
    index-servers = pypi

[pypi]
    username = __token__
    password = pypi-SomeLongString

The twine software package should be installed on your Linux distro. To check if you have twine installed on your machine, run:

$ twine --version

If you do not have twine installed on your machine, you can install it using aptitude or snap package manager (depending on your distro there maybe few other package managers that indexes twine), run the following command to install it using aptitude:

$ sudo apt install twine

Troubleshooting

  • If twine upload says something like the following, …:

    Uploading distributions to https://upload.pypi.org/legacy/
    Uploading lino_react-26.5.1-py3-none-any.whl
    100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 20.8/20.8 MB • 00:06 • 3.7 MB/s
    WARNING  Error during upload. Retry with the --verbose option for more details.
    ERROR    HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/
             Bad Request
    

    … then you might just be trying to re-upload a version you have already uploaded.