[Distutils] virtual-python.py, sys.prefix, and Mac

Chris McDonough chrism at plope.com
Sat Sep 15 19:30:34 CEST 2007

FWIW, the same thing seems to happen for me on Tiger using the  
original virtual-python.py against the Apple-compiled Python that  
ships with it:

[chrism at kingfish macsandbox]$ /usr/bin/python ~/bin/virtual-python.py  
--prefix=.Creating ./lib/python2.3
Creating ./lib/python2.3/site-packages
Creating ./include/python2.3
Creating ./bin
Copying /usr/bin/python to ./bin
You're now ready to download ez_setup.py, and run
./bin/python ez_setup.py
[chrism at kingfish macsandbox]$ ls
bin  include  lib
[chrism at kingfish macsandbox]$ bin/python
Python 2.3.5 (#1, Jan 13 2006, 20:13:11)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> import sys
 >>> sys.prefix

- C

On Sep 15, 2007, at 12:30 PM, Philipp von Weitershausen wrote:

> On 15 Sep 2007, at 18:09 , Ian Bicking wrote:
>> Hi all.  I'm kind of giving up on workingenv, and have started
>> working from virtual-python as a basis instead (http://
>> pypi.python.org/pypi/virtualenv/).
>> So the basic technique here is to copy the executable into /ENV/bin/
>> python, and then sys.prefix will be '/ENV'.  The standard Python
>> installed on a Mac doesn't seem to do this -- the prefix remains '/
>> opt/local/Library/Frameworks/Python.framework/Versions/2.4'
>> regardless.  (Custom built Python's on Mac work like normal.)
> Since I'm the one who's experiencing this, here's some more info:
> * Both the Python 2.4 from MacPorts as well as the binary MacPython
> package fail to create a virtualenv because sys.prefix of the copied
> executable still points to the old location.
> * Self-compiled Python 2.4 and 2.5 doesn't have this problem, nor
> does the Python 2.5 from MacPorts or the MacPython 2.5 binary (!!!)
> So this seems to be constrained to Python 2.4 from MacPorts and
> MacPython.
> _______________________________________________
> Distutils-SIG maillist  -  Distutils-SIG at python.org
> http://mail.python.org/mailman/listinfo/distutils-sig

More information about the Distutils-SIG mailing list