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

Ian Bicking ianb at colorstudy.com
Wed Sep 19 07:26:49 CEST 2007


Ronald Oussoren wrote:
> 
> On 19 Sep, 2007, at 6:25, Ian Bicking wrote:
> 
>> Ronald Oussoren wrote:
>>> On 16 Sep, 2007, at 21:55, Ian Bicking wrote:
>>>> Ronald Oussoren wrote:
>>>>> 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.
>>>>
>>>> I don't really know what that means...?  What exactly is the framework?
>>> The python framework, that is /Library/Frameworks/Python.framework 
>>> (or /System/... if you use Apple's build of Python).  getpath.c uses 
>>> some API calls to determine the absolute path of the python framework 
>>> linked into the current executable and sets sys.prefix to a directory 
>>> inside that framework.
>>
>> Do you have a reference to the getpath.c that it uses?  Windows seems 
>> to have something kind of hardcoded, but also a detection scheme, and 
>> maybe similarly on Mac there's something I can do to avoid the 
>> hardcoded portion.
> 
> It is in the python.org source tree: Modules/getpath.c

That's the file used in the Framework build of Python?  I only see some 
small references to __APPLE__, none of which seem related to Frameworks. 
  Also, if you build Python from source it works fine -- it's only the 
python that Apple ships that has the problem.  They must use some 
patched version of this file that they use...?


-- 
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