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

Ronald Oussoren ronaldoussoren at mac.com
Sun Sep 16 21:49:23 CEST 2007


On 16 Sep, 2007, at 21:44, Ian Bicking wrote:

> Ronald Oussoren 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.)
>> All framework builds behave as you describe, Modules/getpath.c  
>> special-cases calculation of sys.prefix for framework builds of  
>> Python (the prefix is inside the framework regardless of where the  
>> executable is).
>
> Is there any way to effect that calculation?  I.e., in a normal  
> build that calculation is based on the location of the executable,  
> so virtualenv moves the executable to effect that.

Move the framework.

>
>
>>> Does anyone know a way to get the normal effect on this Mac Python?
>> You could copy the framework into the virtual python environment  
>> and rewrite linker commands in the python command-line executable  
>> to use that version of the framework.
>
> That sounds like the similar situation to the standard library on  
> other posix systems, which I've avoided copying.  To do that, I put  
> a text file in that points to the original stdlib location, and in  
> site.py I add that in (I only copy the portions of the stdlib that  
> are needed when site.py is loaded -- os, re, etc).  So the same  
> thing should be possible with the framework, and that's not too much  
> of a problem.
>
>
> I don't have any idea how to figure out the linker commands to  
> change the Python command-line executable...?  I don't even have the  
> vocabulary to begin figuring that out, I'm afraid.  Can you give an  
> example?

macholib (which is on PyPI) can do that. I'm not aware of a command- 
line tool that can do the same thing.

>
>
>
> -- 
> Ian Bicking : ianb at colorstudy.com : http://blog.ianbicking.org
>            : Write code, do good : http://topp.openplans.org/careers



More information about the Distutils-SIG mailing list