Skip to main content
minchin.releaser

Minchin dot Releaser is a tool to make releasing Python packages easier.

PyPI version number Changelog Supported Python version License Download Count

Minchin dot Releaser is currently set up as an invoke task. It is designed to provide a single command to make and publish a release of your Python package. An extra configuration file is an one-time set up requirement to be able to make use of this.

Once set up, Minchin dot Releaser, when run, will:

  • check the configuration

  • confirm all items in the project directory have been added to Git (i.e. that the repo is clean)

  • check that your Readme will render on PyPI

  • sort your import statements

  • vendorize required packages

  • run the test suite

  • update the version number within your code

  • add the release to your changelog

  • build project documentation

  • build your project as a Python distribution

  • confirm your project can be installed from the local machine to the local machine

  • confirm your project can be uploaded to the test PyPI server and then downloaded and installed from this server.

  • confirm your project can be uploaded to the main PyPI server and then downloaded and installed from this server.

  • create a Git tag for your release

  • update your version number to a pre-release version

Minchin dot Releaser relies on features added in the more recent versions of Python, and thus is Python 3 only.

Assumptions

This package makes several assumptions. This is not the only way to do these things, but I have found these choices work well for my use-cases. If you have chosen a different way to set up your project, most of the applicable features will just not work, but the rest of Minchin dot Releaser should continue to work.

It is assumed:

  • this is a Python project.

  • your version is stored in one place in your project, as a string assigned to the variable __version__, that this is one line and there is nothing else on this line. If this is not the case, Minchin dot Releaser will be unable to determine your project’s version number and so won’t be much use to you. This is the project’s one hard requirement in how you organize your code.

  • your version number is importable by Python at <some_module_name>.__version__.

  • source control is done using Git. The Git functionality will be ignored if this is not the case.

Minchin dot Releaser will support both setup.py and pyproject.toml (i.e. PEP 518?) based builds.

Setting Up Your Project

Step 1. Install minchin.releaser.

The simplest way is to use pip:

pip install minchin.releaser

This will also install all the other packages minchin.releaser depends on.

You will also want to add minchin.releaser to the list of your project’s requirements.

Step 2. Create a tasks.py file.

This is where invoke determine was tasks are available to run. This file should be created in the root folder of your project. If you are not using invoke for other tasks, this file can be four lines:

# tasks.py

try:
    from minchin.releaser import make_release
except ImportError:
    print("[WARN] minchin.releaser not installed.")

# your other Invoke tasks...

To confirm that this is working, go to the command line in the root folder of your project, and run:

$ invoke --list

which will now list make-release as an available task.

Step 3. Configure your project.

Project configuration is actually invoke configuration, so it is stored in the invoke.yaml folder in the project root (or anywhere else invoke can load configuration from) under the releaser key.

Available sub-keys:

module_name

(required) the name of your project. It is assumed that your project’s version number is importable at module_name.__version__ (see project assumptions).

pypi_name

(optional) the name of your project as uploaded to PyPI. This only needs to be set if it differs from module_name.

here

(required) the base location to build your package from. To set to the current directory, set to .

docs

(required, but can be set to None) the base documentation directory. This is relative to here.

test

(required, but can be set to None) the base test directory. This is relative to here.

source

(required) the base directory of your Python source code. This is relative to here.

changelog

(required, but can be set to None) the location of your changelog file. This is relative to here.

changelog_version_line

(optional) the line added to your changelog to mark a release. Use the placeholders {version} and {date} (as YYYY-MM-DD). Defaults to (to match the sytle of the `releases <https://github.com/bitprophet/releases>`_ Sphinx extension):

- :release:`{version} <{date}>`
version

(required) the location of where your version string is stored. This is relative to here.

test_command

(required, but can be set to None) command, run from the command line with the current directory set to here, to run your test suite.

version_bump

(optional) default level to bump your version. If set to none, this will be requested at runtime. Valid options include major, minor, bug, and none.

extra_packages

(optional) Used to install packages before installing your module from the server. Useful particularly for packages that need to be installed from cache (rather than re-downloaded and compiled each time) or for packages that are not available on the test PyPI server. Valid server keys are local, test, and pypi. Under the server key, create a list of the packages you want explicitly installed.

(vendorize keys are not listed here.)

Step 4. Set up Invoke command shell (Windows).

Minchin dot Releaser runs certain commands at the command line. Invoke, regardless of platform, tries to run these on /bin/bash which doesn’t exist in Windows and thus these commands fail.

To fix this, create a .invoke.yaml file in the root of your user directory (so the file is C:\Users\<your_username>\.invoke.yaml) and add:

run:
    shell: C:\Windows\system32\CMD.exe

Step 5. Set up twine configuration.

Create or modify $HOME/.pypirc to include the testpypi server:

[distutils]
index-servers=
    pypi
    testpypi

[testpypi]
repository: https://test.pypi.org/legacy/
username: your testpypi username

Minchin dot Releaser is automated, and so needs access to your password. This can be done using keyring. Keyring can be installed by pip and then passwords are added from the command-line.

$ pip install keyring
$ keyring set https://test.pypi.org/legacy/ your-username
$ keyring set https://upload.pypi.org/legacy/ your-username

See Twine Keyring Support for more details.

Step 6. Register your package on PyPI.

(On the new infrastructure, this no longer needs to be done explicitly. Just upload your package.)

Step 7. Upload your package.

$ invoke make-release

And then work through the prompts. If this process breaks half-way through, you can re-start.

In particular, many packages are not available on the test version of PyPI, and will need to iteratively be added to the configuration under the extra_packages.test key.

Credits

Inspired (in part) by https://hynek.me/articles/sharing-your-labor-of-love-pypi-quick-and-dirty/

Sample invoke.yaml

releaser:
    module_name: minchin.releaser
    here: .
    docs: .
    test: None
    source: minchin
    changelog: CHANGELOG.rst
    changelog_version_line: "- :release:`{version} <{date}>`"
    version: minchin\releaser\constants.py
    test_command: "green -kq"
    version_bump: none
    extra_packages:
        test:
            - gitdb
            - invoke
            - isort
            - pkginfo
            - semantic_version
            - twine
            - wheel
        pypi:
            - invoke
    vendor_dest: minchin\releaser\_vendor
    vendor_packages:
        "minchin.text":
            src: ..\minchin.text\minchin
            dest: .
            requirements: ..\minchin.text\requirements.in
    vendor_override_src: vendor_src

Metadata

Release files for minchin.releaser 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for minchin.releaser 0.10.0
File Size Uploaded Provenance
minchin_releaser-0.10.0.tar.gz 31.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for minchin.releaser 0.10.0
File Interpreter ABI Platform
minchin_releaser-0.10.0-py3-none-any.whl Python 3 none any Details

Total release size: 55.5 kB

Release files / minchin_releaser-0.10.0.tar.gz

Download URL minchin_releaser-0.10.0.tar.gz
Size 31.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bc6c2726d8901326b3312c6814189f748970c0548ab9f4a1c8075b59394d4366
BLAKE2b-256 checksum
How to use checksums
eeebb9ee0b4ff6d8287de5bf82760172432ee27c6dbcbc513ffb2f5843bbbb5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Release files / minchin_releaser-0.10.0-py3-none-any.whl

Download URL minchin_releaser-0.10.0-py3-none-any.whl
Size 23.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7965057d29e57ba34da8076a9213795e63cd3ba212c0b8929436341670c54c16
BLAKE2b-256 checksum
How to use checksums
3044a48902495770182f27328f7a53ef151ccc93d8586dd4c5080aca2378cecb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Security for minchin.releaser 0.10.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page