Using hgtools with mercurial tags to automatically version packages

Posted by Drakonen on January 22, 2012 in Uncategorized | Short Link

I liked to automate my python package versioning a bit more and did this with hgtools. With hgtools it is quite easy to store the version numbers only in your repository as tags, and not having it again in setup.py.

A minimal setup.py can look like this:

from setuptools import setup, find_packages
setup(
    name="HelloWorld",
    use_hg_version=True,
    packages=find_packages(),
    setup_requires=["hgtools"],
)

Just give a revision a tag and make an sdist, or bdist and setuptools will use the version from your tag.
Tags have to conform to strict version formatting from distutils to be used by hgtools.

Later I also made it a step in a Jenkins setup, to always build a sdist and copy it to a HTTP accessible directory so it could be installed with pip. This gave me a nice history of available release packages and also, dev versions.

Facebook Twitter Email

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Copyright © 2005-2012 Draakwired All rights reserved.
The Shades theme, version 1.7, is a BuyNowShop.com creation.

Social links powered by Ecreative Internet Marketing