Skip to main content

Minchin.Releaser is a collection of tools designed to make releasing Python packages easier.

Project description

Tools 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.

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
    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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minchin.releaser-0.9.1.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

minchin.releaser-0.9.1-py2.py3-none-any.whl (22.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file minchin.releaser-0.9.1.tar.gz.

File metadata

  • Download URL: minchin.releaser-0.9.1.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.11.6

File hashes

Hashes for minchin.releaser-0.9.1.tar.gz
Algorithm Hash digest
SHA256 be40e0df79d8867ae475e8794a8dd748618e8a096332f695319b40552e23062a
MD5 ac0f4c5432c86f8dd2030f17a53c23e7
BLAKE2b-256 ed2594a2e4e6113801251cb4c6761b359917c22a0b484bccb2640c3698fbd048

See more details on using hashes here.

File details

Details for the file minchin.releaser-0.9.1-py2.py3-none-any.whl.

File metadata

  • Download URL: minchin.releaser-0.9.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.11.6

File hashes

Hashes for minchin.releaser-0.9.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 313f941c19c4a2349bb69a17ea63cbe611c8537915de7c4b4a75856511206865
MD5 7238b7dba1fe06766dbd69f46b778d91
BLAKE2b-256 e28dc371120f9a9868413cde7c88a91e6b355f94b095478b7ced1c8b7d100665

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page