Package: minchin.releaser
Tools to make releasing Python packages easier.Minchin dot Releaseris currently set up as aninvoketask. 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 configurationconfirm 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 PyPIsort your import statementsvendorize required packagesrun the test suiteupdate the version number within your codeadd the release to your changelogbuild project documentationbuild your project as a Python distributionconfirm your project can be installed from the local machine to the local
machineconfirm 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 releaseupdate your version number to a pre-release versionMinchin dot Releaserrelies on features added in the more recent versions of
Python, and thus is Python 3 only.AssumptionsThis 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 ofMinchin dot Releasershould 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 Releaserwill 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 Releaserwill support bothsetup.pyandpyproject.toml(i.e. PEP 518?) based builds.Setting Up Your ProjectStep 1. Installminchin.releaser.The simplest way is to usepip:pip install minchin.releaserThis will also install all the other packagesminchin.releaserdepends
on.You will also want to addminchin.releaserto the list of your
project’s requirements.Step 2. Create atasks.pyfile.This is whereinvokedetermine was tasks are available to run. This file
should be created in the root folder of your project. If you are not usinginvokefor other tasks, this file can be four lines:# tasks.pytry:fromminchin.releaserimportmake_releaseexceptImportError: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--listwhich will now listmake-releaseas an available task.Step 3. Configure your project.Project configuration is actuallyinvokeconfiguration, so it is stored
in theinvoke.yamlfolder in the project root (or anywhere elseinvokecan load configuration from) under thereleaserkey.Available sub-keys:module_name(required) the name of your project. It is assumed that your project’s
version number is importable atmodule_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 frommodule_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 toNone) the base documentation
directory. This is relative tohere.test(required, but can be set toNone) the base test directory. This is
relative tohere.source(required) the base directory of your Python source code. This is
relative tohere.changelog(required, but can be set toNone) the location of your changelog
file. This is relative tohere.version(required) the location of where your version string is stored. This is
relative tohere.test_command(required, but can be set toNone) command, run from the command
line with the current directory set tohere, to run your test suite.version_bump(optional) defaultlevelto bump your version. If set tonone,
this will be requested at runtime. Valid options includemajor,minor,bug, andnone.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 arelocal,test, andpypi. 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).NoteRecent version ofinvokeseem to have resolved this, and this not
longer seems to be needed.Minchin dot Releaserruns certain commands at the command line.Invoke,
regardless of platform, tries to run these on/bin/bashwhich doesn’t exist
in Windows and thus these commands fail.To fix this, create a.invoke.yamlfile in the root of your user directory
(so the file isC:\Users\<your_username>\.invoke.yaml) and add:run:shell:C:\Windows\system32\CMD.exeStep 5. Set up twine configuration.Create or modify$HOME/.pypircto include thetestpypiserver:[distutils]index-servers=pypitestpypi[testpypi]repository:https://test.pypi.org/legacy/username:your testpypi usernameWarningDo not store passwords in the .pypirc file. Storing passwords in plain text
is never a good idea.Minchin dot Releaseris automated, and so needs access to your password. This
can be done usingkeyring. Keyring can be installed bypipand then
passwords are added from the command-line.$pipinstallkeyring$keyringsethttps://test.pypi.org/legacy/your-username$keyringsethttps://upload.pypi.org/legacy/your-usernameSeeTwine Keyring Supportfor 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.$invokemake-releaseAnd 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 theextra_packages\testkey.CreditsInspired (in part) byhttps://hynek.me/articles/sharing-your-labor-of-love-pypi-quick-and-dirty/Sampleinvoke.yamlreleaser:module_name:minchin.releaserhere:.docs:.test:Nonesource:minchinchangelog:changelog.rstversion:minchin\releaser\constants.pytest_command:"green-kq"version_bump:noneextra_packages:test:-gitdb-invoke-isort-pkginfo-semantic_version-twine-wheelpypi:-invokevendor_dest:minchin\releaser\_vendorvendor_packages:"minchin.text":src:..\minchin.text\minchindest:.requirements:..\minchin.text\requirements.invendor_override_src:vendor_src