aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2008-01-03 23:48:02 +0000
committerPJ Eby <distutils-sig@python.org>2008-01-03 23:48:02 +0000
commit8e3c998ec1aeeb87094e75d4fdc86db0ae3a2e1e (patch)
tree2d34b33b80961af38c88a69378347929d5b4d5a3
parenta3a96aed765e2cc401b8dc555bd0e925c9d9a685 (diff)
downloadexternal_python_setuptools-8e3c998ec1aeeb87094e75d4fdc86db0ae3a2e1e.tar.gz
external_python_setuptools-8e3c998ec1aeeb87094e75d4fdc86db0ae3a2e1e.tar.bz2
external_python_setuptools-8e3c998ec1aeeb87094e75d4fdc86db0ae3a2e1e.zip
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
-rwxr-xr-xEasyInstall.txt2
-rwxr-xr-xlauncher.c4
-rwxr-xr-xsetuptools/gui.exebin6656 -> 7168 bytes
-rw-r--r--setuptools/tests/win_script_wrapper.txt39
4 files changed, 40 insertions, 5 deletions
diff --git a/EasyInstall.txt b/EasyInstall.txt
index ab7026cd..dc119674 100755
--- a/EasyInstall.txt
+++ b/EasyInstall.txt
@@ -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.
diff --git a/launcher.c b/launcher.c
index 09e2bafb..c8022505 100755
--- a/launcher.c
+++ b/launcher.c
@@ -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 */
diff --git a/setuptools/gui.exe b/setuptools/gui.exe
index 96521355..53d4ff81 100755
--- a/setuptools/gui.exe
+++ b/setuptools/gui.exe
Binary files differ
diff --git a/setuptools/tests/win_script_wrapper.txt b/setuptools/tests/win_script_wrapper.txt
index 9e4dac93..2d95502e 100644
--- a/setuptools/tests/win_script_wrapper.txt
+++ b/setuptools/tests/win_script_wrapper.txt
@@ -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)
+