Skip to main content

Adds a command to dynamically get the version from the VCS of choice

Project description

Get version from version control instead of hardcoding it into setup.py

introduction

Instead of hardcoding the version in setup.py like this:

setup(
    name='some-dist-name',
    version='1.0',
    ...)

This package allows specifying a VCS command like this:

setup(
    name='some-dist-name',
    version_command='git describe',
    ...)

…Which will then update the version into some-dist-name.egg-info/version.txt, so that the version can also be found if setup.py is being run from a sdist or something.

When it can find the version from either some-dist-name.egg-info/version.txt or the output of the version_command, it will update the version key that is normally used for the version, such as what’s used in the sdist filename and so on.

setup keyword

Instead of specifying the version keyword argument, specify the version_command keyword argument. It can either be a str or a tuple. If it’s a str, it’s interpreted as just the command to execute, for example git describe. If it’s a tuple, it must have two elements, the first must be the command, and the second specifies how to adapt the version string to PEP440 and must one have one of the following values:

None

Do nothing, ignore PEP440 and accept that pip/setuptools will throw warnings

pep440-git-local

Change "1.2.3-10-abc1234" to "1.2.3+git-10-abc1234"

pep440-git-dev or pep440-git

Change "1.2.3-10-abc1234" to "1.2.3dev10"

installation

To use it, just do this:

pip install setuptools-version-command

With the pip of the global python. (Or use --user.)

testing

To test it, run ./setup.py --version.

developing

Within a checkout of this repo:

virtualenv env
env/bin/pip install --editable .
env/bin/python setup.py --version

Make sure that you change the setup.py so that it actually makes use of setuptools-version-command.

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

setuptools-version-command-1.3.2.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

setuptools_version_command-1.3.2-py2-none-any.whl (5.3 kB view details)

Uploaded Python 2

File details

Details for the file setuptools-version-command-1.3.2.tar.gz.

File metadata

File hashes

Hashes for setuptools-version-command-1.3.2.tar.gz
Algorithm Hash digest
SHA256 e4333f97a7a12bd3d8faf9d9db2dce41a73e10661df7ae215443fa77894937f8
MD5 daedeede90f9e78a35531cf285f6b983
BLAKE2b-256 4386fdd92cf40966be3fc838a5dd8cb15b88072a5de5aa1ceb9823f892606809

See more details on using hashes here.

File details

Details for the file setuptools_version_command-1.3.2-py2-none-any.whl.

File metadata

File hashes

Hashes for setuptools_version_command-1.3.2-py2-none-any.whl
Algorithm Hash digest
SHA256 fc839a82cd87b2d3b66e7baa85878e3c3cceebc429ea0b2b840ac393b2ea8622
MD5 c3741f0ea8e516f4794ce1635a5e42b3
BLAKE2b-256 a181fac26535c93458a0d3274adc76dc37755904bb36019089ca8c65e444027f

See more details on using hashes here.

Supported by

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