[Distutils] requiring python 2.5
Rick Ratzel
rlratzel at enthought.com
Fri Jun 15 19:59:15 CEST 2007
> Date: Fri, 15 Jun 2007 11:48:31 -0400
> From: "Phillip J. Eby" <pje at telecommunity.com>
>
> At 12:50 AM 6/15/2007 -0500, Rick Ratzel wrote:
> >(Pdb) l
> > 28 import xmlrpclib
> > 29
> > 30 import pdb
> > 31 pdb.set_trace()
> > 32
> > 33 -> from enthought.traits.api import \
> > 34 Trait, HasTraits, Str, List, Instance, Property
> > 35
> > 36 from enthought.enstaller.enstaller_traits import \
> > 37 CreatableDir, Url
> > 38 from enthought.enstaller.api import \
> >
> >(Pdb) import enthought
> >
> >(Pdb) p enthought.__path__
> >('c:\\python25\\lib\\site-packages\\enstaller-2.1.0b1-py2.5-win32.egg\\enthought',)
> >
> >(Pdb) s
> >--Call--
> > >
> > c:\python25\lib\site-packages\enthought.traits-2.0b2.dev_r12224-py2.5-win32.egg\enthought\traits\api.py(16)<module>()
> >-> """
>
> Okay, so the problem here is that enthought.traits got imported
> *before* the __path__ was set. The __path__ needs to get set before
> any enthought.* imports occur.
Yes, I see now that it does get imported, but unfortunately not by my code.
It's imported as a result of importing pkg_resources, since enthought.traits is
a namespace package. Here's a little more detail:
enstaller
|
- enthought.traits
enstaller.gui
|
- enthought.traits.ui.wx
And here's more pdb inspection:
Z:\>python -m pdb c:\Python25\Scripts\enstaller-script.py
> c:\python25\scripts\enstaller-script.py(3)<module>()
-> __requires__ = 'enstaller==2.1.0b1'
(Pdb) n
> c:\python25\scripts\enstaller-script.py(4)<module>()
-> import sys
(Pdb) n
> c:\python25\scripts\enstaller-script.py(5)<module>()
-> from pkg_resources import load_entry_point
(Pdb) "enthought" in "".join(sys.modules.keys())
False
(Pdb) n
> c:\python25\scripts\enstaller-script.py(7)<module>()
-> sys.exit(
(Pdb) "enthought" in "".join(sys.modules.keys())
True
(Pdb) [sys.modules[p] for p in sys.modules.keys() if p.startswith("enthought.")]
[<module 'enthought.traits.ui' from 'c:\python25\lib\site-packages\enthought.traits-2.0b2.dev_r12224-py2.5-win32.egg\enthought\traits\ui\__init__.pyc'>,
<module 'enthought.traits' from 'c:\python25\lib\site-packages\enthought.traits-2.0b2.dev_r12224-py2.5-win32.egg\enthought\traits\__init__.pyc'>,
<module 'enthought.plugins' from 'c:\python25\lib\site-packages\enthought.plugins.text_editor-2.0b2.dev_r12224-py2.5.egg\enthought\plugins\__init__.pyc'>]
Grasping at straws, I set enthought.__path__ in enstaller-script.py
immediately before and after pkg_resources is imported, only to get the same
results both times.
But when I switch to setuptools 0.7 there are no enthought.traits modules
loaded at all (in fact, the only enthought. modules loaded are the enstaller
ones)...this must have been one of the changes you mentioned. When I step into
the enthought.tratis.api import statement, it finds the traits pkg in the
enstaller egg:
Z:\>enstaller -l setuptools
> c:\python25\lib\site-packages\enstaller-2.1.0b1-py2.5-win32.egg\enthought\enst
aller\session.py(33)<module>()
-> from enthought.traits.api import \
(Pdb) l
28 import xmlrpclib
29
30 import pdb
31 pdb.set_trace()
32
33 -> from enthought.traits.api import \
34 Trait, HasTraits, Str, List, Instance, Property
35
36 from enthought.enstaller.enstaller_traits import \
37 CreatableDir, Url
38 from enthought.enstaller.api import \
(Pdb) [sys.modules[p] for p in sys.modules.keys() if p.startswith("enthought.tra
its")]
[]
(Pdb) for p in [(p, sys.modules[p]) for p in sys.modules.keys() if p.startswith("enthought.")] : print p
('enthought.enstaller.optparse', None)
('enthought.enstaller.re', None)
('enthought.enstaller.session', <module 'enthought.enstaller.session' from 'c:\python25\lib\site-packages\enstaller-2.1.0b1-py2.5-win32.egg\enthought\enstaller\session.pyc'>)
('enthought.enstaller.launcher', <module 'enthought.enstaller.launcher' from 'c:\python25\lib\site-packages\enstaller-2.1.0b1-py2.5-win32.egg\enthought\enstaller\launcher.pyc'>)
('enthought.enstaller.traceback', None)
('enthought.enstaller.url_util', <module 'enthought.enstaller.url_util' from 'c:\python25\lib\site-packages\enstaller-2.1.0b1-py2.5-win32.egg\enthought\enstaller\url_util.pyc'>)
('enthought.enstaller.distutils', None)
('enthought.enstaller.xmlrpclib', None)
('enthought.enstaller.enthought', None)
('enthought.enstaller.getpass', None)
('enthought.enstaller.pkg_resources', None)
('enthought.enstaller.pdb', None)
('enthought.enstaller.types', None)
('enthought.enstaller.time', None)
('enthought.enstaller.tempfile', None)
('enthought.enstaller.os', None)
('enthought.enstaller', <module 'enthought.enstaller' from 'c:\python25\lib\site-packages\enstaller.gui-2.1.0b1-py2.5-win32.egg\enthought\enstaller\__init__.pyc'>)
('enthought.enstaller.sys', None)
('enthought.enstaller.platform', None)
('enthought.enstaller.api', <module 'enthought.enstaller.api' from 'c:\python25\lib\site-packages\enstaller-2.1.0b1-py2.5-win32.egg\enthought\enstaller\api.pyc'>)
('enthought.enstaller.site', None)
('enthought.enstaller.main', <module 'enthought.enstaller.main' from 'c:\python25\lib\site-packages\enstaller-2.1.0b1-py2.5-win32.egg\enthought\enstaller\main.pyc'>)
('enthought.enstaller.urllib', None)
('enthought.enstaller.downloader', <module 'enthought.enstaller.downloader' from 'c:\python25\lib\site-packages\enstaller-2.1.0b1-py2.5-win32.egg\enthought\enstaller\downloader.pyc'>)
('enthought.enstaller.urlparse', None)
('enthought.enstaller.text_io', <module 'enthought.enstaller.text_io' from 'c:\python25\lib\site-packages\enstaller-2.1.0b1-py2.5-win32.egg\enthought\enstaller\text_io.pyc'>)
(Pdb) s
--Call--
> c:\python25\lib\site-packages\enstaller-2.1.0b1-py2.5-win32.egg\enthought\traits\__init__.py(22)<module>()
-> try:
(Pdb) c
------------------------------------------------------------
name | version | act | location
------------------------------------------------------------
setuptools | 0.6c6 | n | c:\python25\lib\site-packages
setuptools | 0.7a1dev_r53614 | Y | c:\python25\lib\site-packages
> >(Pdb) p enthought.__path__
> >('c:\\python25\\lib\\site-packages\\enstaller-2.1.0b1-py2.5-win32.egg\\enthought',)
> >
> >(Pdb) s
> >ImportError: 'No module named traits.api'
> > >
> > c:\python25\lib\site-packages\enstaller-2.1.0b1-py2.5-win32.egg\enthought\enstaller\session.py(33)<module>()
> >-> from enthought.traits.api import \
> >
> >
> > I get a different ImportError now.
>
> It appears that enthought.traits is not available in the enstaller
> egg; have you checked that?
I wish! Unfortunately it is. This is how Enstaller is able to work when no
other enthought eggs are installed, or when I use setuptools 0.7. You can see
the path to it in the pdb session above.
Phillip, I really appreciate the time you're taking to look at this. I'm
going to release a version which simply requires setuptools 0.7...unless you
think that's a terrible idea, or you discover that I'm doing something wrong
that I can fix.
--
Rick Ratzel - Enthought, Inc.
515 Congress Avenue, Suite 2100 - Austin, Texas 78701
512-536-1057 x229 - Fax: 512-536-1059
http://www.enthought.com
More information about the Distutils-SIG
mailing list