[Patches] [ python-Patches-1038911 ] OS X: Can't use
#!/usr/bin/pythonw
SourceForge.net
noreply at sourceforge.net
Mon Oct 4 22:16:43 CEST 2004
Patches item #1038911, was opened at 2004-10-02 02:40
Message generated for change (Comment added) made by n8gray
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1038911&group_id=5470
Category: Macintosh
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Nathan Gray (n8gray)
Assigned to: Jack Jansen (jackjansen)
Summary: OS X: Can't use #!/usr/bin/pythonw
Initial Comment:
At the moment, on OS X /usr/bin/pythonw2.x is a simple sh script
that exec's a python interpreter within a valid OS X application
bundle. The problem is that this prevents python scripts from
using pythonw in the #! line. Darwin won't allow a script to act as
an interpreter in a #! line.
This patch replaces the shell script with a simple C program that
does the same thing -- it just calls execv on the python interpreter
within the OS X app bundle. Since it is a compiled executable it is
allowed to act as an interpreter in #! lines.
Your patch guidelines said you preferred multiple patches to be
concatenated in a single file. My patch consists of a Makefile
change and a new file, dist/src/Mac/OSX/pythonw.c. I've included
both in the text file attached to this report. It would probably be
prudent for somebody to review the Makefile change, since it's
always tricky to find the right way to put a new file in someone
else's build process.
Thank you,
-Nathan
----------------------------------------------------------------------
>Comment By: Nathan Gray (n8gray)
Date: 2004-10-04 13:16
Message:
Logged In: YES
user_id=121553
The issue is that sometimes you *do* care where python is installed, and
you want to be sure to get the system python and not, for example, the
Fink python. At the moment, the only solution is to use a gangly #! line
like:
#! /System/Library/Frameworks/Python.framework/Resources/
Python.app/Contents/MacOS/Python
and you'll only figure that out if you're clever enough to understand why
#!/usr/bin/python works but #!/usr/bin/pythonw doesn't.
Mainly, it's just needlessly confusing to have a python interpreter that
works from the command line but doesn't work in a #! line. It's
unfortunate that the distinction between python and pythonw is
necessary, but as long as it is then it would be nice if at least pythonw
was able to act as a drop-in replacement for python. It's pretty simple
to make it work as expected, so why not do it, for the sake of
consistency?
----------------------------------------------------------------------
Comment By: Nick Coghlan (ncoghlan)
Date: 2004-10-04 07:34
Message:
Logged In: YES
user_id=1038590
As described in the python tutorial, the recommended
solution to this is to use the following on the shebang line:
#! /usr/bin/env pythonw
this also has benefit of not caring where python is installed.
----------------------------------------------------------------------
Comment By: Nathan Gray (n8gray)
Date: 2004-10-02 18:00
Message:
Logged In: YES
user_id=121553
Assigning to Jack Jansen as suggested by Bob Ippolito on pythonmac-sig.
----------------------------------------------------------------------
Comment By: Nathan Gray (n8gray)
Date: 2004-10-02 02:43
Message:
Logged In: YES
user_id=121553
By the way, the patch is against CVS head.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1038911&group_id=5470
More information about the Patches
mailing list