Fix script launcher creation on 64-bit Windows, patch by Jason R. Coombs (http://bugs.python.org/setuptools/issue2)

--HG--
branch : distribute
extra : rebase_source : 60c07b0639b77a3e8ff13eb12161ebe03ab47430
This commit is contained in:
agronholm 2009-09-25 22:01:27 +03:00
parent 758eba50d9
commit efa78ba0a0
9 changed files with 29 additions and 5 deletions

View File

@ -25,8 +25,9 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <process.h>
#include <fcntl.h>
#include "tchar.h"
#include "windows.h"
int fail(char *format, char *data) {
@ -236,11 +237,18 @@ int run(int argc, char **argv, int is_gui) {
}
/* We *do* need to wait for a CLI to finish, so use spawn */
return spawnv(P_WAIT, ptr, (const char * const *)(newargs));
return _spawnv(_P_WAIT, ptr, (const char * const *)(newargs));
}
/*
int WINAPI WinMain(HINSTANCE hI, HINSTANCE hP, LPSTR lpCmd, int nShow) {
return run(__argc, __argv, GUI);
}
*/
int _tmain(int argc, _TCHAR* argv[])
{
return run(argc, argv, GUI);
}

15
msvc-build-launcher.cmd Normal file
View File

@ -0,0 +1,15 @@
@echo off
REM VCVARSALL may be in Program Files or Program Files (x86)
PATH=C:\Program Files\Microsoft Visual Studio 9.0\VC;%PATH%
PATH=C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC;%PATH%
REM set up the environment to compile to x86
call VCVARSALL x86
cl /D "GUI=0" /D "WIN32_LEAN_AND_MEAN" launcher.c /O2 /link /MACHINE:x86 /out:setuptools/cli-32.exe
cl /D "GUI=1" /D "WIN32_LEAN_AND_MEAN" launcher.c /O2 /link /MACHINE:x86 /out:setuptools/gui-32.exe
REM now for 64-bit
call VCVARSALL x86_amd64
cl /D "GUI=0" /D "WIN32_LEAN_AND_MEAN" launcher.c /O2 /link /MACHINE:x64 /out:setuptools/cli-64.exe
cl /D "GUI=1" /D "WIN32_LEAN_AND_MEAN" launcher.c /O2 /link /MACHINE:x64 /out:setuptools/gui-64.exe

BIN
setuptools/cli-32.exe Normal file

Binary file not shown.

BIN
setuptools/cli-64.exe Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1603,13 +1603,14 @@ def get_script_args(dist, executable=sys_executable, wininst=False):
")\n"
) % locals()
if sys.platform=='win32' or wininst:
word_size = [32, 64]['amd64' in sys.version.lower()]
# On Windows/wininst, add a .py extension and an .exe launcher
if group=='gui_scripts':
ext, launcher = '-script.pyw', 'gui.exe'
ext, launcher = '-script.pyw', 'gui-%d.exe' % word_size
old = ['.pyw']
new_header = re.sub('(?i)python.exe','pythonw.exe',header)
else:
ext, launcher = '-script.py', 'cli.exe'
ext, launcher = '-script.py', 'cli-%d.exe' % word_size
old = ['.py','.pyc','.pyo']
new_header = re.sub('(?i)pythonw.exe','python.exe',header)

BIN
setuptools/gui-32.exe Normal file

Binary file not shown.

BIN
setuptools/gui-64.exe Normal file

Binary file not shown.

Binary file not shown.