Bugs item #713601, was opened at 2003-04-01 23:40 Message generated for change (Comment added) made by gbrandl You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=713601&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: Python 2.3 >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Lalo Martins (lalo) Assigned to: Nobody/Anonymous (nobody) Summary: site.py breaks if prefix is empty Initial Comment: verified in 2.3a1 and 2.2.2: prefixes = [sys.prefix] if sys.exec_prefix != sys.prefix: prefixes.append(sys.exec_prefix) for prefix in prefixes: if prefix: # do stuff - in particular, define the "sitedir" variable # and add site-packages to the path del prefix, sitedir if sys.prefix == sys.exec_prefix and both are empty (which is the case if you compile with --prefix=/ as for the Gnu OS for example), this will have two unfortunate results: 1. site-packages will not be added to the path. 2. site.py will abort with a NameError (it tries to del sitedir which isn't defined) The fix seems to be as simple as removing the "if prefix" line. From mailing list archives, it seems to have been added to cope with unusual loading environments related to windows and COM - in this case, there is probably a safer way to check for this condition. If the prefix is empty, this just means it's the root, and no further assumptions should be made. ---------------------------------------------------------------------- >Comment By: Georg Brandl (gbrandl) Date: 2006-02-20 17:38 Message: Logged In: YES user_id=849994 Fixed in rev. 42522, 42523. ---------------------------------------------------------------------- Comment By: Daniel Goertzen (goertzen) Date: 2004-08-09 21:38 Message: Logged In: YES user_id=843814 Refer to patch 931938. Incidentally someone else just complained that I forgot to actually upload the file, so I just put it there today. The patch fixes the prefix search as described in step 3 in the comments of getpath.c. Looking at the code that the patch fixes, it should be pretty easy to see how the reduce() function can chop the path down to an empty string when prefix and exec_prefix are the root directory. ---------------------------------------------------------------------- Comment By: Brett Cannon (bcannon) Date: 2004-08-09 20:47 Message: Logged In: YES user_id=357491 The 2.3 maintenance branch is the CVS version of the 2.3 tree. But if you tried this against 2.3.4 chances are that is close enough. Unfortunately under OS X I get '/' for sys.prefix and not an empty string so I can't debug this. ---------------------------------------------------------------------- Comment By: Daniel Goertzen (goertzen) Date: 2004-08-09 15:03 Message: Logged In: YES user_id=843814 Not too sure what you mean by maintenance branch, but 2.3.4 and today's CVS python/dist/src tree still produced an empty string for sys.prefix when configured with --prefix=/ FYI, I install my root pefix python into a separate directory by running "make install prefix=mydir". "mydir" is the root filesystem for an embedded device that we make. For testing, I chroot to mydir and can run python. The overall procedure is: ./configure --prefix=/ make make install prefix=mydir chroot mydir python I don't think the install and chroot shenanigans make any difference, but I thought I'd mention it in case I'm doing something dumb. ---------------------------------------------------------------------- Comment By: Brett Cannon (bcannon) Date: 2004-08-07 21:39 Message: Logged In: YES user_id=357491 I just tried compiling on the 2.3 maintenance branch with --prefix=/ and I had sys.prefix be set to '/'. Can you check to see if you are still having sys.prefix set to an empty string? ---------------------------------------------------------------------- Comment By: Brett Cannon (bcannon) Date: 2004-08-07 19:58 Message: Logged In: YES user_id=357491 The NameError problem has been fixed. ---------------------------------------------------------------------- Comment By: Daniel Goertzen (goertzen) Date: 2004-04-08 19:09 Message: Logged In: YES user_id=843814 See this patch: 931938 prefix and exec_prefix as root dir bug ---------------------------------------------------------------------- Comment By: Daniel Goertzen (goertzen) Date: 2004-04-08 16:01 Message: Logged In: YES user_id=843814 Just ran into the same problem when I configure with --prefix=/ The problem is in getpath.c. Before trying to find your lib/python dir based on what you submitted in configure, it performs a search based on the python execution path (probably /bin). It keeps chopping the path down with the reduce() function and then adds "/lib/python" and sees if a landmark file is there. The problem is that reduce() will freely chop away the last / leaving your prefix as a null string. I'm going to try tweaking reduce() so it doesn't hack off the last / if its the last one. ---------------------------------------------------------------------- Comment By: Brett Cannon (bcannon) Date: 2003-06-08 22:54 Message: Logged In: YES user_id=357491 Why is sys.prefix == '' if it is set to '/' as the command-line argument? Checking Modules/getpath.c there appears a few places where things could go awry if an enviroment variable is set that causes the code to think it has already found the location before it reaches what the Makefile set PREFIX and EXEC_PREFIX to. The steps used are in the initial comment of the file. Any of those a possible reason for your problem? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=713601&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com