Commit 8e3c998e authored by PJ Eby's avatar PJ Eby

Backport gui.exe launcher fix.

--HG--
branch : setuptools-0.6
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4059684
parent a3a96aed
......@@ -1237,6 +1237,8 @@ Release Notes/Change History
* Prevent ``--help-commands`` and other junk from showing under Python 2.5
when running ``easy_install --help``.
* Fixed GUI scripts sometimes not executing on Windows
0.6c7
* ``ftp:`` download URLs now work correctly.
......
......@@ -231,8 +231,8 @@ int run(int argc, char **argv, int is_gui) {
if (is_gui) {
/* Use exec, we don't need to wait for the GUI to finish */
execv(python, (const char * const *)(newargs));
return fail("Could not exec %s", python); /* shouldn't get here! */
execv(ptr, (const char * const *)(newargs));
return fail("Could not exec %s", ptr); /* shouldn't get here! */
}
/* We *do* need to wait for a CLI to finish, so use spawn */
......
No preview for this file type
......@@ -5,8 +5,7 @@ setuptools includes wrappers for Python scripts that allows them to be
executed like regular windows programs. There are 2 wrappers, once
for command-line programs, cli.exe, and one for graphica programs,
gui.exe. These programs are almost identical, function pretty much
the same way, and are generated from the same source file. In this
document, we'll demonstrate use of the command-line program only. The
the same way, and are generated from the same source file. The
wrapper programs are used by copying them to the directory containing
the script they are to wrap and with the same name as the script they
are to wrap. In the rest of this document, we'll give an example that
......@@ -68,13 +67,14 @@ This example was a little pathological in that it exercised windows
- One or more backslashes preceding double quotes quotes need to be
escaped by preceding each of them them with back slashes.
Specifying Python Command-line Options
--------------------------------------
You can specify a single argument on the '#!' line. This can be used
to specify Python options like -O, to run in optimized mode or -i
to start the interactive interpreter. You can combine multiple
options as usual. For example, to run in optimized mode and
options as usual. For example, to run in optimized mode and
enter the interpreter after running the script, you could use -Oi:
>>> open(os.path.join(sample_directory, 'foo-script.py'), 'w').write(
......@@ -97,8 +97,41 @@ enter the interpreter after running the script, you could use -Oi:
''
---
Testing the GUI Version
-----------------------
Now let's test the GUI version with the simple scipt, bar-script.py:
>>> import os, sys, tempfile
>>> from setuptools.command.easy_install import nt_quote_arg
>>> sample_directory = tempfile.mkdtemp()
>>> open(os.path.join(sample_directory, 'bar-script.pyw'), 'w').write(
... """#!%(python_exe)s
... import sys
... open(sys.argv[1], 'wb').write(repr(sys.argv[2]))
... """ % dict(python_exe=nt_quote_arg(sys.executable)))
We'll also copy gui.exe to the sample-directory with the name bar.exe:
>>> import pkg_resources
>>> open(os.path.join(sample_directory, 'bar.exe'), 'wb').write(
... pkg_resources.resource_string('setuptools', 'gui.exe')
... )
Finally, we'll run the script and check the result:
>>> import os
>>> input, output = os.popen4('"'+nt_quote_arg(os.path.join(sample_directory, 'bar.exe'))
... + r' "%s" "Test Argument"' % os.path.join(sample_directory, 'test_output.txt'))
>>> input.close()
>>> print output.read()
<BLANKLINE>
>>> print open(os.path.join(sample_directory, 'test_output.txt'), 'rb').read()
'Test Argument'
We're done with the sample_directory:
>>> import shutil
>>> shutil.rmtree(sample_directory)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment