summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2005-11-17 03:01:33 +0000
committerPJ Eby <distutils-sig@python.org>2005-11-17 03:01:33 +0000
commit0c4fd22a1736c2e6a17744f0bed1be55997415c3 (patch)
tree06f049af5190d18f6838eef85b47a3fcd382ded3
parent5a44729bbb5170b1c63c57002e7a903bec2537e9 (diff)
downloadpython-setuptools-bitbucket-0c4fd22a1736c2e6a17744f0bed1be55997415c3.tar.gz
Quote arguments to python.exe (including python's path) to avoid
problems when Python (or a script) is installed in a directory whose name contains spaces. :(
-rwxr-xr-xlauncher.c20
-rwxr-xr-xsetuptools/cli.exebin5632 -> 6144 bytes
-rwxr-xr-xsetuptools/gui.exebin5632 -> 6144 bytes
3 files changed, 10 insertions, 10 deletions
diff --git a/launcher.c b/launcher.c
index b5405911..1bb1097f 100755
--- a/launcher.c
+++ b/launcher.c
@@ -1,5 +1,4 @@
-/*
- Setuptools Script Launcher for Windows
+/* Setuptools Script Launcher for Windows
This is a stub executable for Windows that functions somewhat like
Effbot's "exemaker", in that it runs a script with the same name but
@@ -23,7 +22,6 @@
starting. So, we have to use spawnv() and wait for Python to exit before
continuing. :(
*/
-
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
@@ -35,9 +33,11 @@ int fail(char *format, char *data) {
fprintf(stderr, format, data);
return 2;
}
-
-
-
+char *quoted(char *data) {
+ char *result = calloc(strlen(data)+3,sizeof(char));
+ strcat(result,"\""); strcat(result,data); strcat(result,"\"");
+ return result;
+}
int run(int argc, char **argv, int is_gui) {
@@ -96,19 +96,19 @@ int run(int argc, char **argv, int is_gui) {
/* Argument array needs to be argc+1 for args, plus 1 for null sentinel */
newargs = (char **)calloc(argc+2, sizeof(char *));
- newargs[0] = python;
- newargs[1] = script;
+ newargs[0] = quoted(python);
+ newargs[1] = quoted(script);
memcpy(newargs+2, argv+1, (argc-1)*sizeof(char *));
newargs[argc+1] = NULL;
/* printf("args 0: %s\nargs 1: %s\n", newargs[0], newargs[1]); */
if (is_gui) {
/* Use exec, we don't need to wait for the GUI to finish */
- execv(newargs[0], (const char * const *)(newargs));
+ execv(python, (const char * const *)(newargs));
return fail("Could not exec %s", python); /* shouldn't get here! */
}
/* We *do* need to wait for a CLI to finish, so use spawn */
- return spawnv(P_WAIT, newargs[0], (const char * const *)(newargs));
+ return spawnv(P_WAIT, python, (const char * const *)(newargs));
}
diff --git a/setuptools/cli.exe b/setuptools/cli.exe
index 4da0b584..fc833396 100755
--- a/setuptools/cli.exe
+++ b/setuptools/cli.exe
Binary files differ
diff --git a/setuptools/gui.exe b/setuptools/gui.exe
index 056f554f..63ff35f4 100755
--- a/setuptools/gui.exe
+++ b/setuptools/gui.exe
Binary files differ