Builds a pythonic version number based on scm tags and branches
Project description
setup_scmversion
Builds a pythonic version number based on information available on your scm (tag, branch, and number of commits).
See LICENSE for important licensing information.
Instalation
Your setup.py
will need jfaleiro.setup_scmversion
to start - so you either make sure you have it pre-installed using pip:
pip install jfaleiro.setup-scmversion
Use
A pythonic version number is created from standard data available in your scm, i.e. tag, branch name, and number of differences from master.
Simplest Use
Should apply to most projects. Assumes your project has one main package. For this example let's name this package mypackage
. After installation add this to your setup.py
:
import mypackage
...
setup( ...
version=mypackage.__version__),
...
)
Add this to your mypackage.py
or mypackage.__init__.py
:
from ._version import __version__
Done. Now you just have to make sure you execute scmversion tag-version
after installation and before any setuptools
task that requires a version:
scmversion tag-version
...
python setup.py sdist # or any other command that requires a tagged version
Examples of other possible setup commands are develop
, install
, bdist
, and others.
To know usage details refer to scmversion --help
Way More Complicated
Add this on the very top of your setup.py
and forget about it moving forward.
try:
import setup_scmversion
except ModuleNotFoundError as e:
from pip._internal import main
assert main('install jfaleiro.setup-scmversion'.split()) == 0
from setup_scmversion import version
Add these parameters to your version
and setup_requires
parameters in setup.py
:
setup(
version=version(),
...
setup_requires=['jfaleiro.setup-scmversion'],
...
)
Versioning Schema
Release tags release/<version>
with nnn
differences from master will produce version <version>.dev<nnn>
and a tagged version <tag>
on master will produce the version <tag>
. Everything else will produce master.dev<nnn>
for master or no-version.dev<nnn>
for any other branch.
You can also use a command line based shortcut to peek at the current version:
jfaleiro@itacoatiara:~/gitrepos/setup_scmversion (release/0.0.1 *+)$ scmversion version
0.0.1.dev1
or the type of version, i.e.:
jfaleiro@itacoatiara:~/gitrepos/setup_scmversion (release/0.0.1 *+)$ scmversion version-type
RELEASE_BRANCH
The type of release can be one of RELEASE
, RELEASE_BRANCH
, FEATURE_BRANCH
, or OTHER
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
Hashes for jfaleiro.setup_scmversion-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b632d7c8b759d4f3aec09c8f80faaa0bab193ed128213f337be18309ab64ce2 |
|
MD5 | 5234fe6bba6dced6a652db8f302d83b2 |
|
BLAKE2b-256 | c8d8b855ce2eb212eaca612e434ce3b825f8fa4906aa9f5af6fdf7c48e9cb750 |