At 09:05 PM 5/19/2009 -0400, Jean-Paul Calderone wrote:
On Tue, 19 May 2009 20:49:37 -0400, "P.J. Eby" <[email protected]> wrote:
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.
I don't think I'm ready to make setuptools a mandatory dependency yet.
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.
That's an idea that's come up before. I'm curious to here if anyone has
tried it and what their experiences have been.
Oh, now that I think of it, there is one other thing that I've
done. For some of my packages (including setuptools itself), I use a
script that automatically searches and replaces version numbers, and
stores the current version number in a configuration file. Another
configuration file specifies what files to edit and what format to
insert the numbers in. So, I just do a quick command line like
'./version incr build' to increment the most-minor version number in
the docs, the setup.py, and even to edit my release script.
And I suppose one last idea that you could use would be to define
your version string in the module in such a way that setup.py could
read it with a regular expression match, so it wouldn't be actually
executing the code.
_______________________________________________
Distutils-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/distutils-sig