Plugin for Poetry to enable dynamic versioning based on VCS tags for semver
Project description
Dynamic versioning plugin for Poetry
This package is a plugin for Poetry to enable dynamic versioning based on tags in your version control system, powered by Scmver.
Since Poetry does not yet officially support plugins (refer to this issue) as of the time of writing on 2019-12-10, this package takes some novel liberties to make the functionality possible. As soon as official support lands, this plugin will be updated to do things the official way.
Installation
Python 3.5 (or newer) and Poetry 0.12.1 (or newer) are required.
- Run
pip install poetry-scmver
- Add this to your pyproject.toml:
[tool.scmver] enable = true
Note that you must install the plugin in your global Python installation, not as a dependency in pyroject.toml, because the virtual environment that Poetry creates cannot see Poetry itself and therefore cannot patch it.
Configuration
In your pyproject.toml file, you may configure the following options:
[tool.scmver]
: General options.
-
enable
: Boolean. Default: false. Since the plugin has to be installed globally, this setting is an opt-in per project. This setting will likely be removed once plugins are officially supported. -
root
: A path of the working directory. Default:'.'
-
spec
: A version specifier to construct the public version indentifiers. It will be incremented by the number of commits from the latest tag.major
: It will increment the major version.minor
: It will increment the minor version.micro
orpatch
: It will increment the micro (patch) version.post
: It will increment the post-release segment.major.dev
: It will increment the development release segment after incrementing the major version by 1.minor.dev
: It will increment the development release segment after incrementing the minor version by 1.micro.dev
orpatch.dev
: It will increment the development release segment after incrementing the micro (patch) version by 1.
Default:
'post'
-
local
: Astring
to construct the local version identifiers.Available keywords:
{distance}
{reivison}
{branch}
{utc}
- Return value ofdatetime.datetime.utcnow()
{local}
- Return value ofdatetime.datetime.now()
Default:
'{local:%Y-%m-%d}'
-
version
: A regular expression object to extract the version from SCM tags. It should contain the version group. -
write_to
: A path to a file which will be generated usingtemplate
. -
template
: A format string which is used bywrite_to
. Available keywords:{version}
{revision}
{branch}
-
bazaar.tag
: A regular expression pattern to filter tags. -
fossil.tag
: A regular expression pattern to filter tags. -
git.tag
: It will be passed togit describe
as--match
. -
mercurial.tag
: A regular expression pattern to filter tags. -
subversion.tag
: A regular expression pattern to filter tags. -
subversion.trunk
: A relative repository path of the trunk directory. Default:'trunk'
-
`subversion.branches: A relative repository path of the directory where branches are located. Default:
'branches'
-
subversion.tags
: A relative repository path of the directory where tags are located. Default:'tags'
Simple example:
[tool.semver]
enable = true
write_to = "version.py"
Implementation
In order to side-load plugin functionality into Poetry, this package does the following:
- Upon installation, it delivers a
zzz_poetry_semver.pth
file to your Python site-packages directory. This forces Python to automatically load the plugin after all other modules have been loaded (or at least those alphabetically prior tozzz
). - It patches
builtins.__import__
so that, whenever the first import from Poetry finishes,poetry.console.main
will be patched. The reason we have to wait for a Poetry import is in case you've used the get-poetry.py script, in which case there is a gap between when Python is fully loaded and when~/.poetry/bin/poetry
adds the Poetry lib folder to the PYTHONPATH. - The patched version of
poetry.console.main
will then, when called, additionally patch eitherpoetry.poetry.Poetry.create()
orpoetry.factory.Factory.create_poetry()
(depending on your Poetry version) to replace the version from your pyproject.toml file with the dynamically generated version.
Changelog
See Changelog
License
See License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file poetry-scmver-0.1.2.dev6.tar.gz
.
File metadata
- Download URL: poetry-scmver-0.1.2.dev6.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.7.4 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63239d032c6928b5b7936420809d030911c73fdbb7670909c7a6ea086ac1e4f1 |
|
MD5 | 8db67da5d78f231aa8e8f430e66a4b50 |
|
BLAKE2b-256 | 9db5743c0e6374274444823f2fc1de5729bb3fdc4f4547238a3f963120983040 |
File details
Details for the file poetry_scmver-0.1.2.dev6-py3-none-any.whl
.
File metadata
- Download URL: poetry_scmver-0.1.2.dev6-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.7.4 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d6c07964152f221fc18df48759a6f4603482c135f200064b6a663212b73e6ca |
|
MD5 | 5f0e4c77dcafc781c5a8edd00de435d8 |
|
BLAKE2b-256 | 76b80d28dd22527aa6742c38786cc9f277aee07874b150d37a5d1b744d9a45cc |