GitLab's annual major release is around the corner. Along with a lot of new and exciting features, there will be a few breaking changes. Learn more here.

README.rst 1.46 KB
Newer Older
Craig Weber's avatar
Craig Weber committed
1 2 3 4 5 6 7 8 9
python-versiontag
=============================

.. image:: https://img.shields.io/pypi/v/versiontag.svg
    :target: https://pypi.python.org/pypi/versiontag

.. image:: https://img.shields.io/pypi/dm/versiontag.svg
        :target: https://pypi.python.org/pypi/versiontag

Craig Weber's avatar
Craig Weber committed
10 11
.. image:: https://travis-ci.org/thelabnyc/python-versiontag.svg
    :target: https://travis-ci.org/thelabnyc/python-versiontag
Craig Weber's avatar
Craig Weber committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

What?
-----

This is an ultra-simple library design to make accessing the current version number of
your software easy.

Why?
----

Version numbers are all too often duplicated among setup.py, git tags, and others sources
of truth. This library makes it possible to consolidate on git tags as a single source of
truth regarding version numbers.

How?
----

Install python-versiontag using pip.

Craig Weber's avatar
Craig Weber committed
31 32
.. code:: bash

Craig Weber's avatar
Craig Weber committed
33 34 35 36
    pip install versiontag

Add version.txt to your .gitignore file.

Craig Weber's avatar
Craig Weber committed
37 38
.. code:: bash

Craig Weber's avatar
Craig Weber committed
39 40 41 42
    echo "version.txt" >> .gitignore

Add versiontag to your package's setup.py file.

Craig Weber's avatar
Craig Weber committed
43 44
.. code:: python

Craig Weber's avatar
Craig Weber committed
45 46 47 48 49 50 51 52 53 54
    from versiontag import get_version, cache_git_tag

    # This caches for version in version.txt so that it is still accessible if
    # the .git folder disappears, for example, after the slug is built on Heroku.
    cache_git_tag()

    setup(name='My Package',
          version=get_version(pypi=True),
    ...

Craig Weber's avatar
Craig Weber committed
55

Craig Weber's avatar
Craig Weber committed
56 57
Use versiontag where ever you want to access the version number.

Craig Weber's avatar
Craig Weber committed
58 59
.. code:: python

Craig Weber's avatar
Craig Weber committed
60 61 62
    >>> from versiontag import get_version
    >>> print( get_version() )
    'r1.2.3'