On 06/02/2008, Christian Heimes <[EMAIL PROTECTED]> wrote: > 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?
One major issue: The same launcher cannot be used for py and pyw files. The launcher for py files needs to be compiled as a console app, whereas the launcher for pyw (GUI) files needs to be compiled as a GUI app. On Windows, GUI vs Console is a property of the EXE file, and the differing behaviour is built into the OS loader. You may not like the fact (at times, I certainly don't) but you can't fight it. Trying to avoid this is what makes GUI apps with consoles that flash up quickly before disappearing, and other similar nastiness. Also, be aware that Python does not *have* to register itself in the registry (AIUI). But other things (like bdist_wininst IIRC) expect it, so as long as you don't fail too horribly if there's no registry entries, you should be OK. Finally, you don't want to change the current directory. Suppose I had a simple program listdir.py that displayed the contents of the current directory. Using your wrapper would break it. Why do you think changing directory is needed, as opposed to making sys.path look like you want - oh, hang on, you're running python.exe so you have no access to sys.path. Hmm, your proposal may have a more serious problem than I realised. Paul. _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
