Author: mattip <[email protected]>
Branch:
Changeset: r77475:13206861eb60
Date: 2015-05-22 07:54 +0300
http://bitbucket.org/pypy/pypy/changeset/13206861eb60/
Log: merge pypyw which provides pypyw.exe as well as pypy.exe on win32
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -117,4 +117,12 @@
.. branch: cffi-1.0
+branch cffi-1.0
PyPy now includes CFFI 1.0.
+
+.. branch: pypyw
+
+branch pypyw
+PyPy on windows provides a non-console pypyw.exe as well as pypy.exe.
+Similar to pythonw.exe, any use of stdout, stderr without redirection
+will crash.
diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py
--- a/pypy/tool/release/package.py
+++ b/pypy/tool/release/package.py
@@ -142,6 +142,12 @@
pypydir.ensure('include', dir=True)
if sys.platform == 'win32':
+ src,tgt = binaries[0]
+ pypyw = src.new(purebasename=src.purebasename + 'w')
+ if pypyw.exists():
+ tgt = py.path.local(tgt)
+ binaries.append((pypyw, tgt.new(purebasename=tgt.purebasename +
'w').basename))
+ print "Picking %s" % str(pypyw)
# Can't rename a DLL: it is always called 'libpypy-c.dll'
win_extras = ['libpypy-c.dll', 'sqlite3.dll']
if not options.no_tk:
diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -293,7 +293,7 @@
bk = self.translator.annotator.bookkeeper
return getfunctionptr(bk.getdesc(self.entrypoint).getuniquegraph())
- def cmdexec(self, args='', env=None, err=False, expect_crash=False):
+ def cmdexec(self, args='', env=None, err=False, expect_crash=False,
exe=None):
assert self._compiled
if sys.platform == 'win32':
#Prevent opening a dialog box
@@ -314,9 +314,10 @@
envrepr = ''
else:
envrepr = ' [env=%r]' % (env,)
- log.cmdexec('%s %s%s' % (self.executable_name, args, envrepr))
- res = self.translator.platform.execute(self.executable_name, args,
- env=env)
+ if exe is None:
+ exe = self.executable_name
+ log.cmdexec('%s %s%s' % (exe, args, envrepr))
+ res = self.translator.platform.execute(exe, args, env=env)
if sys.platform == 'win32':
SetErrorMode(old_mode)
if res.returncode != 0:
diff --git a/rpython/translator/c/test/test_standalone.py
b/rpython/translator/c/test/test_standalone.py
--- a/rpython/translator/c/test/test_standalone.py
+++ b/rpython/translator/c/test/test_standalone.py
@@ -845,6 +845,13 @@
#Do not set LD_LIBRARY_PATH, make sure $ORIGIN flag is working
out, err = cbuilder.cmdexec("a b")
assert out == "3"
+ if sys.platform == 'win32':
+ # Make sure we have a test_1w.exe
+ # Since stdout, stderr are piped, we will get output
+ exe = cbuilder.executable_name
+ wexe = exe.new(purebasename=exe.purebasename + 'w')
+ out, err = cbuilder.cmdexec("a b", exe = wexe)
+ assert out == "3"
def test_gcc_options(self):
# check that the env var CC is correctly interpreted, even if
diff --git a/rpython/translator/driver.py b/rpython/translator/driver.py
--- a/rpython/translator/driver.py
+++ b/rpython/translator/driver.py
@@ -458,11 +458,14 @@
shutil_copy(str(fname), str(dstname))
self.log.info('Static data info written to %s' % dstname)
- def compute_exe_name(self):
+ def compute_exe_name(self, suffix=''):
newexename = self.exe_name % self.get_info()
if '/' not in newexename and '\\' not in newexename:
newexename = './' + newexename
- return py.path.local(newexename)
+ newname = py.path.local(newexename)
+ if suffix:
+ newname = newname.new(purebasename = newname.purebasename + suffix)
+ return newname
def create_exe(self):
""" Copy the compiled executable into current directory, which is
@@ -478,6 +481,11 @@
shutil_copy(str(soname), str(newsoname))
self.log.info("copied: %s" % (newsoname,))
if sys.platform == 'win32':
+ # Copy pypyw.exe
+ newexename = mkexename(self.compute_exe_name(suffix='w'))
+ exe = py.path.local(exename)
+ exename = exe.new(purebasename=exe.purebasename + 'w')
+ shutil_copy(str(exename), str(newexename))
# the import library is named python27.lib, according
# to the pragma in pyconfig.h
libname = str(newsoname.dirpath().join('python27.lib'))
diff --git a/rpython/translator/platform/windows.py
b/rpython/translator/platform/windows.py
--- a/rpython/translator/platform/windows.py
+++ b/rpython/translator/platform/windows.py
@@ -260,6 +260,8 @@
if shared:
so_name = exe_name.new(purebasename='lib' + exe_name.purebasename,
ext=self.so_ext)
+ wtarget_name = exe_name.new(purebasename=exe_name.purebasename +
'w',
+ ext=self.exe_ext)
target_name = so_name.basename
else:
target_name = exe_name.basename
@@ -313,11 +315,13 @@
('MAKE', 'nmake.exe'),
('_WIN32', '1'),
]
+ if shared:
+ definitions.insert(0, ('WTARGET', wtarget_name.basename))
if self.x64:
definitions.append(('_WIN64', '1'))
rules = [
- ('all', '$(DEFAULT_TARGET)', []),
+ ('all', '$(DEFAULT_TARGET) $(WTARGET)', []),
('.asm.obj', '', '$(MASM) /nologo /Fo$@ /c $< $(INCLUDEDIRS)'),
]
@@ -411,14 +415,33 @@
'int main(int argc, char* argv[]) '
'{ return $(PYPY_MAIN_FUNCTION)(argc, argv); } > $@')
deps = ['main.obj']
+ m.rule('wmain.c', '',
+ ['echo #define WIN32_LEAN_AND_MEAN > $@',
+ 'echo #include "windows.h" >> $@',
+ 'echo int $(PYPY_MAIN_FUNCTION)(int, char*[]); >> $@',
+ 'echo int WINAPI WinMain( >> $@',
+ 'echo HINSTANCE hInstance, /* handle to current
instance */ >> $@',
+ 'echo HINSTANCE hPrevInstance, /* handle to previous
instance */ >> $@',
+ 'echo LPSTR lpCmdLine, /* pointer to command
line */ >> $@',
+ 'echo int nCmdShow /* show state of window
*/ >> $@',
+ 'echo ) >> $@',
+ 'echo { return $(PYPY_MAIN_FUNCTION)(__argc, __argv); }
>> $@'])
+ wdeps = ['wmain.obj']
if icon:
deps.append('icon.res')
+ wdeps.append('icon.res')
m.rule('$(DEFAULT_TARGET)', ['$(TARGET)'] + deps,
['$(CC_LINK) /nologo /debug %s ' % (' '.join(deps),) + \
'$(SHARED_IMPORT_LIB) /out:$@ ' + \
'/MANIFEST /MANIFESTFILE:$*.manifest',
'mt.exe -nologo -manifest $*.manifest
-outputresource:$@;1',
])
+ m.rule('$(WTARGET)', ['$(TARGET)'] + wdeps,
+ ['$(CC_LINK) /nologo /debug /SUBSYSTEM:WINDOWS %s ' % ('
'.join(wdeps),) + \
+ '$(SHARED_IMPORT_LIB) /out:$@ ' + \
+ '/MANIFEST /MANIFESTFILE:$*.manifest',
+ 'mt.exe -nologo -manifest $*.manifest
-outputresource:$@;1',
+ ])
m.rule('debugmode_$(DEFAULT_TARGET)', ['debugmode_$(TARGET)']+deps,
['$(CC_LINK) /nologo /DEBUG %s ' % (' '.join(deps),) + \
'debugmode_$(SHARED_IMPORT_LIB) /out:$@',
diff --git a/rpython/translator/test/test_driver.py
b/rpython/translator/test/test_driver.py
--- a/rpython/translator/test/test_driver.py
+++ b/rpython/translator/test/test_driver.py
@@ -53,17 +53,21 @@
dst_name = udir.join('dst/pypy.exe')
src_name = udir.join('src/dydy2.exe')
+ wsrc_name = udir.join('src/dydy2w.exe')
dll_name = udir.join('src/pypy.dll')
lib_name = udir.join('src/pypy.lib')
pdb_name = udir.join('src/pypy.pdb')
src_name.ensure()
src_name.write('exe')
+ wsrc_name.ensure()
+ wsrc_name.write('wexe')
dll_name.ensure()
dll_name.write('dll')
lib_name.ensure()
lib_name.write('lib')
pdb_name.ensure()
pdb_name.write('pdb')
+ # Create the dst directory
dst_name.ensure()
class CBuilder(object):
@@ -76,6 +80,7 @@
assert dst_name.read() == 'exe'
assert dst_name.new(ext='dll').read() == 'dll'
assert dst_name.new(purebasename='python27',ext='lib').read() == 'lib'
+ assert dst_name.new(purebasename=dst_name.purebasename + 'w').read() ==
'wexe'
def test_shutil_copy():
if os.name == 'nt':
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit