A library for versioning your Python projects. (LADI project)
Go to file
Amber Brown (HawkOwl) df177b96c1 more stuff :D 2015-11-29 23:09:05 +08:00
src more stuff :D 2015-11-29 23:09:05 +08:00
tests clean things up 2015-11-29 21:45:59 +08:00
.coveragerc setup.py and things 2015-11-29 21:57:37 +08:00
.gitignore setup.py and things 2015-11-29 21:57:37 +08:00
LICENSE more stuff :D 2015-11-29 23:09:05 +08:00
README.rst more stuff :D 2015-11-29 23:09:05 +08:00
examplesetup.py more stuff :D 2015-11-29 23:09:05 +08:00
setup.py more stuff :D 2015-11-29 23:09:05 +08:00
tox.ini setup.py and things 2015-11-29 21:57:37 +08:00

README.rst

Incremental
===========

Incremental is a small library that versions your Python projects.


Quick Start
-----------

Add this to the top of your ``setup.py``, assuming your code is called ``widgetbox``:

.. code::

    my_project = 'widgetbox'

    import os, importlib

    def install_incremental():
        import importlib
        try:
            importlib.import_module('incremental')
        except ImportError:
            import pip
            pip.main(['install', 'incremental>=0.1.0'])
        finally:
            globals()['incremental'] = importlib.import_module('incremental')

    install_incremental()

    # PICK ONE OF:
    # If you have a src/ dir
    base_dir = os.path.dirname(__file__)
    src_dir = os.path.join(base_dir, "src")
    # If you do not
    src_dir = os.path.dirname(__file__)

    version = incremental.get_version_from_project(my_project, src_dir)

And in the ``setup`` call, add:

.. code::

   setup(
       name=my_project,
       version=version.base(),
       ...
   }

Then in your project add a ``_version.py`` that contains:

.. code::

   from incremental import Version

   __version__ = Version("widgetbox", 1, 2, 3)
   __all__ = ["__version__"]


Then in your project's ``__init__.py`` add:

.. code::

   from ._version import __version__


Subsequent installations of your project will use incremental for versioning.