[Distutils] Specifying version information once

P.J. Eby pje at telecommunity.com
Tue May 19 22:23:16 CEST 2009


At 02:21 PM 5/19/2009 -0400, Jean-Paul Calderone wrote:
>Hello,
>
>For a long time, the idiom I've used to specify version information in my
>distutils-based packages has been this simple one: put version information
>into the Python package somewhere, structure the source layout so that the
>package can be imported directly from an unpacked source tarball (or vcs wc),
>and import the version into setup.py.  This worked great.  And I only had to
>define my version once.
>
>Increasingly, it seems that new distutils-related tools don't support this
>idiom and break in various ways.  (eg
>
>  http://divmod.org/trac/ticket/2629
>  http://divmod.org/trac/ticket/2831
>)
>
>What is the recommendation for specifying version information in a way which
>is compatible with all these new tools?

Don't import the file with your version info; execfile() it instead.

That is, you can have a somepackage.version module for importing, but 
from within your setup.py, do execfile('somepackage/version.py') 
instead, so as to avoid actually importing your package (and anything 
it depends on).



More information about the Distutils-SIG mailing list