[Python-bugs-list] [ python-Bugs-455537 ] module search in import.c

noreply@sourceforge.net noreply@sourceforge.net
Wed, 05 Sep 2001 11:28:07 -0700


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

Category: Build
Group: Python 2.1.1
>Status: Closed
>Resolution: Works For Me
Priority: 5
Submitted By: Armin Steinhoff (arminsteinhoff)
>Assigned to: Guido van Rossum (gvanrossum)
Summary: module search in import.c

Initial Comment:
I'm porting 2.1.1 to QNX6 and got the situation that the module 'os' could not
be be found with 'import os'

After some hacking with DDD .. I found out that the pathes used by the search
algorithm of import.c has nothing to do with the directory structure of the UNIX
distribution of Python 2.1.1 =:-/

I have installed Python in the root directory and set PYTHONHOME/PYTHONPATH to
/Python-2.1.1 -> the path to he library modules is then

                     -> /Python-2.1.1/Lib   OK ... that's not a clean place for UNIX freaks :)

The search algorithm of import.c is using the following search path sequence:

  "os.so"   -> I don't know why it should make sense to open
               a shared object with fopen ??
  "osmodule.so"
  "os.py"
  "os.pyc"

  "/Python-2.1.1/os.so" ... os.pyc

  "/Python-2.1.1/lib/python2.1/os.so" ... os.pyc
                ^^^^^^^^^^^^^^^ who got the idea that this is part of the 
                                                  UNIX tar.gz distribution ??

Also ... there are similar problems with the binaries installed by 'make install' ...

Armin

a-steinhoff@web.de

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

>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-09-05 11:28

Message:
Logged In: YES 
user_id=6380

Closing this report -- the submitter has what he wants (a
clue).

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

Comment By: Armin Steinhoff (arminsteinhoff)
Date: 2001-09-05 06:52

Message:
Logged In: YES 
user_id=64602


OK ... the directories "lib/python2.1" are not part of the UNIX sources, but they are used in the search
sequence.

Yes ... your last statement is correct :-)

However ... I will look into the 'getpath' module in order to modify the default search path for QNX6

Armin

 

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-08-31 05:37

Message:
Logged In: YES 
user_id=6380

Ignoring your original message (which I didn't understand)
but clued in by your latest followup (which makes sense to
me):

The Unix and Windows getpath code accommodates this case
(running from the build directory) by noticing this and
choosing a different default path in that case. Maybe you
should do the same in your QNX port. The relevant code for
Unix is in Modules/getpath.c (not in import.c, which is one
of the reasons why your initial message threw me off).

Regarding the search algorithm: it uses fopen() to detect
existence of the file. Read the source and it will be clear
to you: it has a table of suffixes to try. I don't
understand your remark "who got the idea that this is part
of the UNIX tar.gz distribution ??" My feeling is that
you're jumping to conclusions based on insufficient
knowledge, which makes it hard to argue. :-)

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

Comment By: Armin Steinhoff (arminsteinhoff)
Date: 2001-08-31 01:47

Message:
Logged In: YES 
user_id=64602


Hello Jeremy,

The location of the standard Phython libraries are valid for 
a binary installation ... but not for the structure of the 
source distribution, that means for the build process 
(setup.py).

For instance os.py is located in $(PYTHONHOME)/Lib and not 
in ${prefix}/lib/python<version> ! 

This creates an import error when setup.py will be executed.

.... and this is exactly the problem!

Armin 

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

Comment By: Jeremy Hylton (jhylton)
Date: 2001-08-27 15:20

Message:
Logged In: YES 
user_id=31392

I'm not sure what the complaint is.  The man page for Python
is quite clear about what PYTHONHOME means:

Change the location of the standard Python libraries.  By
default, the
libraries are searched in ${prefix}/lib/python<version> and
${exec_prefix}/lib/python<version>, where ${prefix} and
${exec_prefix}
are installation-dependent directories, both defaulting to
\fI/usr/local\fP.  When $PYTHONHOME is set to a single
directory, its value
replaces both ${prefix} and ${exec_prefix}.  To specify
different values
for these, set $PYTHONHOME to ${prefix}:${exec_prefix}.

It sounds like Python is doing exactly what it is documented
to do.


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

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