Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] How *does* Python determine sys.prefix?

Greg Wardgward@mems-exchange.org
Tue, 11 Apr 2000 22:10:18 -0400


Ooh, here's a yucky problem.  Last night, I installed Oliver Andrich'sPython 1.5.2 RPM on my Linux box at home, so now I have two Pythoninstallations there:  * my build, in /usr/local/python and /usr/local/python.i86-linux    (I need to test Distutils in the prefix != exec_prefix case)  * Oliver's RPM, in /usrI have a symlink /usr/local/bin/python pointing to../../python.i86-linux/bin/python, and /usr/local/bin is first in mypath:  $ ls -lF `which python`  lrwxrwxrwx   1 root     root           30 Aug 28  1999 /usr/local/bin/python -> ../python.i86-linux/bin/python*Since I installed the RPM, /usr/local/bin/python reports an incorrectprefix:  $ /usr/local/bin/python  Python 1.5.2 (#1, Jun 20 1999, 19:56:42)  [GCC 2.7.2.3] on linux2  Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam  >>> import sys ; sys.prefix, sys.exec_prefix  ('/usr', '/usr/local/bin/../python.i86-linux')Essentially the same thing if I run it directly, not through thesymlink:  $ /usr/local/python.i86-linux/bin/python  Python 1.5.2 (#1, Jun 20 1999, 19:56:42)  [GCC 2.7.2.3] on linux2  Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam  >>> import sys ; sys.prefix, sys.exec_prefix  ('/usr', '/usr/local/python.i86-linux')/usr/bin/python gets it right, though:  $ /usr/bin/python  Python 1.5.2 (#1, Apr 18 1999, 16:03:16)  [GCC pgcc-2.91.60 19981201  (egcs-1.1.1  on linux2  Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam  >>> import sys ; sys.prefix, sys.exec_prefix  ('/usr', '/usr')This strikes me as a pretty reasonable and straightforward way to havemultiple Python installations; if Python is fooled into getting thewrong sys.prefix, then the Distutils are going to have a much tougherjob!  Don't tell me I have to write my own prefix-finding code now...(And no, I have not tried this under 1.6 yet.)Damn and blast my last-minute pre-release testing... I should have justreleased the bloody thing and let the bugs fly.  Oh hell, I think I willanyways.        Greg-- Greg Ward - software developergward@mems-exchange.orgMEMS Exchange / CNRI                           voice: +1-703-262-5376Reston, Virginia, USA                            fax: +1-703-262-5367


[8]ページ先頭

©2009-2025 Movatter.jp