[Distutils] patches: ez_setup.py: don't import setuptools into your current address space in order to learn its version number
zooko
zooko at zooko.com
Thu Oct 4 23:00:48 CEST 2007
On Oct 3, 2007, at 5:20 PM, Phillip J. Eby wrote:
> del sys.modules['pkg_resources']
>
> after upgrading setuptools, as long as it wasn't there to start with.
There's something about this that I don't understand. How is
deleting the name from sys.modules different from reloading it, which
as you already explained [1] is not going to work?
I can think of two approaches that will work for python >= 2.3:
1. Import setuptools to get a copy of its __version__ attribute,
import pkg_resources to use its parse_version() function, then del
them from sys.modules. (As above, I don't understand how deleting
them from sys.modules and then importing them is different from
reloading them.)
2. Use os.system() instead of subprocess() to get the version of the
installed setuptools, include a copy of the parse_version() function
from pkg_resources.
The second approach seems clean and robust to me, and I would be
happy to submit a patch that does it if you are interested in seeing
one.
Regards,
Zooko
[1] http://mail.python.org/pipermail/distutils-sig/2007-September/
008309.html
More information about the Distutils-SIG
mailing list