[Python-bugs-list] [ python-Bugs-433775 ] module build dir first in test import

noreply@sourceforge.net noreply@sourceforge.net
Wed, 23 Jan 2002 05:45:31 -0800


Bugs item #433775, was opened at 2001-06-16 10:21
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=433775&group_id=5470

Category: Build
Group: Platform-specific
Status: Open
Resolution: Works For Me
Priority: 5
Submitted By: Sjoerd Mullender (sjoerd)
Assigned to: Sjoerd Mullender (sjoerd)
Summary: module build dir first in test import

Initial Comment:
This problem was found on a Linux (RedHat 7.1) system,
but applies to all Unix systems.

In the step "python setup.py build", after a shared
module is built, setup checks whether it can import the
module.  During this test, the build directory should
be at the beginning of sys.path to make sure you get
the module that was actually built.  Currently, the
build directory is at the end.

----------------------------------------------------------------------

>Comment By: Thomas Heller (theller)
Date: 2002-01-23 05:45

Message:
Logged In: YES 
user_id=11105

I have the impression that sjoerd wants a sys.path of 
['/ufs/sjoerd/src/Python/dist/src/build.irix646/build/lib.ir
ix64-6.5-2.2'] before the module import is tried.

Maybe something like (warning, untested!)
        oldpath = sys.path
        sys.path = self.build_dir
        try:
            __import__(ext.name)
        except ImportError:
            self.announce('WARNING: removing "%s" since 
importing it failed' %
                          ext.name)
        sys.path = oldpath


----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2002-01-23 05:07

Message:
Logged In: YES 
user_id=6656

Well, I was fairly sure I didn't understand the problem,
that why I was asking questions a month ago.

I still don't see a real problem; if
/ufs/sjoerd/lib/my-python is not on the path, we can be
pretty sure about all the others except maybe site-packages,
and that's after the build directory anyway.

Has this really caused you problems?  Feel free to change
the code in site.py to something you're happy with.  If sf
is being as tedious to you as it is to me, maybe we can hash
this out in email.

----------------------------------------------------------------------

Comment By: Sjoerd Mullender (sjoerd)
Date: 2002-01-23 04:51

Message:
Logged In: YES 
user_id=43607

I'm reopening this. I'm not sure you really understand the problem.
Python -E doesn't do anything here.  At the time the newly built module is imported (line 172 in setup.py in the 
current version 1.76), the value of sys.path is (in my environment) ['..', '/ufs/sjoerd/lib/my-python', '', 
'/ufs/sjoerd/lib/my-python', '/ufs/sjoerd/src/Python/dist/src/Lib', '/ufs/sjoerd/src/Python/dist/src/Lib/lib-tk', 
'/ufs/sjoerd/src/Python/dist/src/build.irix646/Modules', 
'/ufs/sjoerd/src/Python/dist/src/build.irix646/build/lib.irix64-6.5-2.2', '/ufs/sjoerd/lib/python2.2/site-packages'].
python -E will remove the second entry since that is the only one in my PYTHONPATH. (Note, I build in a 
subdirectory of the one where setup.py is located, hence the first entry.) However, an older version of the newly 
built module may well be in one of the other directories.  The point is, when setup tries to import the newly built 
module, it should try *only* the build/lib.* directory *and nothing else*.  Otherwise the check is not valid.

----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2002-01-23 03:05

Message:
Logged In: YES 
user_id=6656

Closing.

----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2001-12-24 05:32

Message:
Logged In: YES 
user_id=6656

Um.  Is this actually a problem now we have python -E?

(this would be easy enough to fix, though, after I actually 
found the code that puts the build dir in sys.path -- it's in 
site.py, of all places).


----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2001-12-24 05:16

Message:
Logged In: YES 
user_id=6656




----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=433775&group_id=5470