This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ronaldoussoren
Recipients loewis, ronaldoussoren
Date 2009-09-04.06:10:52
SpamBayes Score 9.648902e-08
Marked as misclassified No
Message-id <1252044655.92.0.0549362149651.issue6834@psf.upfronthosting.co.za>
In-reply-to
Content
Let me first explain in more detail why pythonw is needed in the first 
place: MacOSX only allows access to a large number of GUI-related APIs 
from application bundles (the symbols are of course always available, 
but the APIs fail when you are calling them from an executable that is 
not in an application bundle)

This is why we introduced pythonw in framework builds of Python. Pythonw 
is a small executable that does nothing else but execv the real python 
interpreter that is in and .app bundle inside the Python framework 
(Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Pytho
n). The full path to the execv-ed interpreter is hardcoded into the 
pythonw executable.

To be able to switch between 32-bit and 64-bit versions of Python a 4-
way universal build of Python creates 3 variations of the Python 
executable inside the .app bundle: Python-32, Python-64 and Python (the 
latter being 4-way universal).  There are also 3 variations of the 
pythonw executable (such as pythonw-32) that execv the proper version of 
the interpreter.

Using posix_spawn and the other API's I mention it should be fairly easy 
to create a simpler situation where we need only one copy of Python in 
the .app bundle, with the pythonw wrapper selecting the required 
architecture(s) before executing the real interpreter.

Making pythonw fully reusable by virtualenv requires some more work, and 
requires more support code in virtualenv itself as well. One fairly easy 
way to accomplish easy reusability without requiring a C compiler is to 
use a large buffer for storing the path to the real interpreter, 
virtualenv could then patch the executable. 

Another option is to link the pythonw executable to Python.framework and 
then use dyld APIs to find the path to the Python framework and from 
that the executable.

As an aside, virtualenv copies the shared library in Python.framework 
into virtual environments, this is needed because the framework build 
uses the location of that shared library to determine sys.prefix.
History
Date User Action Args
2009-09-04 06:10:56ronaldoussorensetrecipients: + ronaldoussoren, loewis
2009-09-04 06:10:55ronaldoussorensetmessageid: <1252044655.92.0.0549362149651.issue6834@psf.upfronthosting.co.za>
2009-09-04 06:10:53ronaldoussorenlinkissue6834 messages
2009-09-04 06:10:52ronaldoussorencreate