[openbiblio-dev] Mercurial Dependencies for Version info in Python Packages

William Waites william.waites at okfn.org
Tue Jul 6 16:14:57 UTC 2010

This just came up on IRC, Rufus suggested bringing it up
on the list.

In the ordf/ontosrv/openbiblio python packages, I've
introduced an optional dependency on mercurial so that
package version numbers can be made automatically:

version = '0.5'
    from mercurial import ui, hg, error
    repo = hg.repository(ui.ui(), ".")
    ver = repo[version]
except ImportError:
except error.RepoLookupError:
    tip = repo["tip"]
    version = version + ".%s.%s" % (tip.rev(), tip.hex()[:12])

This makes pretty version numbers as in,

Finished processing dependencies for ordf==

If there's a tag for the current version it will use that (so no
minor version, changeset hash)

Is this a terrible idea?


William Waites           <william.waites at okfn.org>
Mob: +44 789 798 9965    Open Knowledge Foundation
Fax: +44 131 464 4948                Edinburgh, UK

RDF Indexing, Clustering and Inferencing in Python

More information about the openbiblio-dev mailing list