[Python-3000] [Python-ideas] Namespaces are one honking great idea -- let's do more of those!

Christian Heimes lists at cheimes.de
Wed Feb 6 19:37:47 CET 2008


Phillip J. Eby wrote:
> FYI, setuptools uses and supports #! lines on Windows, with the 
> executable path in quotes if it contains spaces.  For a given script 
> "foo", it generates two files:
> 
>      foo.exe
>      foo-script.py
> 
> And the .exe is just a standardized .exe file that looks in an 
> adjacent -script.py file of the same name for the #! line.

Nice, it's an elegant and easy solution to the problem. I like to get a
quite similar solution into the core but I propose a slightly different
path.

Like your launcher.c, spam.exe looks for spam.py. It additionally looks
for spam.pyw first giving .pyw files a higher priority.

The first line of the file is read and parsed. The line must start with
a shebang (#!). Contrary to your script it doesn't look for a complete
path but searches for pythonX.Y. "#!python2.5" or "#!/usr/bin/python2.5"
both work.

Then the launcher executable queries the installation path of Python X.Y
from the registry (first HKCU, then HKLM). At last the script is
executed with the Python binary: python.exe for .py and pythonw.exe for
.pyw. The working directory is the absolute path of spam.exe. This way
we neither have to change the paths for Windows scripts nor quote the
path name.

Comments?

Christian


More information about the Python-3000 mailing list