[Baypiggies] version in python package distributions, argh

Ian Zimmerman itz at buug.org
Mon Jan 23 05:50:50 CET 2012

How do people manage the version number in the setup.py file of your
distributions?  I have distributions that contain exectuable scripts.  I
like those scripts to have a -V or --version command line option like
other well behaved programs.  Unless I do something clever, this leads
to duplication of the version info in at least 2 places, with
predictable um, results.

So, I did try something clever:

from distutils.core import setup
import subprocess

sp = subprocess.Popen(['./hgit', '--version'], stdout=subprocess.PIPE)
vline = sp.stdout.read()
prog, version = vline.strip().split()

setup (name = 'hgit',
       version = version,


only to discover that during installation from a source package the
script file is not necessarily executable, which will crash any
invocation of setup.py.

What other ways are there to solve this annoying situation?

Ian Zimmerman
gpg public key: 1024D/C6FF61AD
fingerprint: 66DC D68F 5C1B 4D71 2EE5  BD03 8A00 786C C6FF 61AD
Rule 420: All persons more than eight miles high to leave the court.

More information about the Baypiggies mailing list