If you're reporting an issue for setuptools 0.7 or higher, please use BitBucket

Title Shebang for gui_scripts on Windows should be #!pythonw.exe for MSI installers, too
Priority bug Status chatting
Superseder Nosy List AndiDog, pje
Assigned To Keywords

Created on 2010-08-24.19:54:19 by AndiDog, last changed 2010-10-04.16:39:05 by pje.

msg563 (view) Author: pje Date: 2010-10-04.16:39:05
Note on a possible fix: we could always use the relative version if installing scripts to $PREFIX/Scripts.  As long as somebody doesn't retarget the script directory (via config file or command line), this would work.  I'll try to put together a patch.
msg536 (view) Author: pje Date: 2010-08-24.22:20:07
Hm.  It appears that the real issue here is that setuptools doesn't include any bdist_msi-specific support at all, and bdist_msi is using --prefix instead of --root, so setuptools normal bdist detection isn't working.

As for the absolute path, it's required because setuptools' script launchers (cli.exe and gui.exe) actually use the path encoded in the #! line to do the launching.  So, if the desired executable is not on PATH, it won't work.  The special case handling of a non-absolute path is for bdist_wininst only, because bdist_wininst installs scripts in a fixed location relative to the python executable.  This allows the launcher to take advantage of this.

However, in a normal (non-bdist_wininst) installation, the script can be installed literally *anywhere* -- so the relative version can't be used under normal circumstances.

That means this code needs to check specifically for bdist_msi as well.
msg535 (view) Author: AndiDog Date: 2010-08-24.19:54:18
This is a follow up to the following problem:

If I create a MSI installer from a Python package with a computer that has its Python installation in 'C:\Program Files\Python26', and install it on another computer that has it installed in 'C:\Python26', for example, the shebang (for a script in gui_scripts) will still be #!"C:\Program Files\Python26\pythonw.exe"

With bdist_wininst installers, this problem does not occur because the code makes a distinction for them:

    if wininst:
        executable = "python.exe"
        executable = nt_quote_arg(executable)

In case of a MSI installer, wininst is False and the full absolute path of pythonw.exe is inserted. I can't understand why an absolute path should be necessary. Using a #!pythonw.exe shebang line works even if the matching Python installation is not in the PATH or an incompatible Python version is in the PATH. So I propose to change that first line to

    if wininst or sys.platform == "win32":
Date User Action Args
2010-10-04 16:39:05pjesetmessages: + msg563
2010-08-24 22:20:08pjesetstatus: unread -> chatting
nosy: + pje
messages: + msg536
2010-08-24 19:54:19AndiDogcreate