At 03:24 PM 4/10/2011 +0000, exar...@twistedmatrix.com wrote:
On 04:02 am, p...@telecommunity.com wrote:
At 08:52 AM 4/10/2011 +1000, Ben Finney wrote:
This is an often-overlooked case, I think. The unspoken assumption is
often that ``setup.py`` is a suitable place for the overall version
string, but this is not the case when that string must be read by
non-Python programs.
If you haven't used the distutils a lot, you might not realize that
you can do this:
$ python setup.py --version
0.6c12
(The --name option also works, and they can be used together -- the
answers will be on two separate lines.)
This only works as long as setup.py is around - which it typically
no longer is after installation is complete.
And though it's common and acceptable enough to launch a child
process in a shell script in order to get some piece of information,
it isn't as pleasant in a Python program. Can you get this version
information out of setup.py without running a child process and
without monkey-patching sys.argv and sys.stdout?
I was replying to the part above about "setup.py ... must be read by
non-Python programs".
In other words, I thought the question was, "given a
not-yet-installed source package, how can we find the version number
without writing Python code". Your question is a bit different. ;-)
As it happens, if you have a source distribution of a package, you
can expect to find a PKG-INFO file that contains version info anyway,
generated from the source file. This is true for both distutils and
setuptools-built source distributions. (It is not the case, alas,
for simple revision control checkouts.)
Anyway, I was merely addressing the technical question of how to get
information from the tools that already exist, rather than advocating
any solutions.
And, along that same line, monkeypatching sys.argv and sys.stdout
aren't technically necessary for you to get the information from a
setup script, but a sandbox to keep the setup script from trying to
do any installation steps is probably a good idea. (Some people have
written setup scripts that actually copy files or do other things
before they even call setup(). Nasty -- and one of the reasons that
easy_install has a sandboxing facility.)
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com