At 04:28 PM 5/19/2009 -0400, Jean-Paul Calderone wrote:
On Tue, 19 May 2009 16:23:16 -0400, "P.J. Eby" <[email protected]> wrote:
At 02:21 PM 5/19/2009 -0400, Jean-Paul Calderone wrote:
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).
execfile() doesn't set __name__ properly; setting __name__ in a namespace
passed to execfile() produces a CPython SystemError. At the moment my
version code depends on __name__ being set. I'm sure I could work around
this, but it'd be better if I didn't have to worry about code in the
version module being executed in two unrelated contexts. Any other
suggestions?
Well, if you're okay with depending on setuptools, you could have
your version code do this:
version = pkg_resources.require('ThisProject')[0].version
And *only* define the version in setup.py, but don't import or run that code.
Of, if you can't depend on setuptools (no pun intended), the only
other thing I can think of would be to put the version in a text file
by itself, and have both the version code and setup.py read that file.
_______________________________________________
Distutils-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/distutils-sig