[pypy-commit] pypy default: Windows: add a translation config to give the name of the .lib file.
arigo
pypy.commits at gmail.com
Mon Feb 15 04:25:18 EST 2016
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r82250:c6d3343b23cc
Date: 2016-02-15 10:08 +0100
http://bitbucket.org/pypy/pypy/changeset/c6d3343b23cc/
Log: Windows: add a translation config to give the name of the .lib file.
Use it to change "libpypy-c.lib" into "..\..\libs\python27.lib".
Other related fixes to package and use the result. (thanks matti for
starting)
diff --git a/lib-python/2.7/distutils/command/build_ext.py b/lib-python/2.7/distutils/command/build_ext.py
--- a/lib-python/2.7/distutils/command/build_ext.py
+++ b/lib-python/2.7/distutils/command/build_ext.py
@@ -188,7 +188,7 @@
# the 'libs' directory is for binary installs - we assume that
# must be the *native* platform. But we don't really support
# cross-compiling via a binary install anyway, so we let it go.
- self.library_dirs.append(os.path.join(sys.exec_prefix, 'include'))
+ self.library_dirs.append(os.path.join(sys.exec_prefix, 'libs'))
if self.debug:
self.build_temp = os.path.join(self.build_temp, "Debug")
else:
diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -239,6 +239,9 @@
raise Exception("Cannot use the --output option with PyPy "
"when --shared is on (it is by default). "
"See issue #1971.")
+ if sys.platform == 'win32':
+ config.translation.libname = '..\\..\\libs\\python27.lib'
+ thisdir.join('..', '..', 'libs').ensure(dir=1)
if config.translation.thread:
config.objspace.usemodules.thread = True
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
@@ -108,13 +108,8 @@
#
builddir = py.path.local(options.builddir)
pypydir = builddir.ensure(name, dir=True)
+
includedir = basedir.join('include')
- # Recursively copy all headers, shutil has only ignore
- # so we do a double-negative to include what we want
- def copyonly(dirpath, contents):
- return set(contents) - set( # XXX function not used?
- shutil.ignore_patterns('*.h', '*.incl')(dirpath, contents),
- )
shutil.copytree(str(includedir), str(pypydir.join('include')))
pypydir.ensure('include', dir=True)
@@ -129,9 +124,6 @@
win_extras = ['libpypy-c.dll', 'sqlite3.dll']
if not options.no_tk:
win_extras += ['tcl85.dll', 'tk85.dll']
- # add the .lib too, which is convenient to compile other programs
- # that use the .dll (and for cffi's embedding mode)
- win_extras.append('libpypy-c.lib')
for extra in win_extras:
p = pypy_c.dirpath().join(extra)
@@ -142,22 +134,27 @@
continue
print "Picking %s" % p
binaries.append((p, p.basename))
- importlib_name = 'python27.lib'
- if pypy_c.dirpath().join(importlib_name).check():
- shutil.copyfile(str(pypy_c.dirpath().join(importlib_name)),
- str(pypydir.join('include/python27.lib')))
- print "Picking %s as %s" % (pypy_c.dirpath().join(importlib_name),
- pypydir.join('include/python27.lib'))
+ libsdir = basedir.join('libs')
+ if libsdir.exists():
+ print 'Picking %s (and contents)' % libsdir
+ shutil.copytree(str(libsdir), str(pypydir.join('libs')))
else:
- pass
- # XXX users will complain that they cannot compile cpyext
- # modules for windows, has the lib moved or are there no
- # exported functions in the dll so no import library is created?
+ print '"libs" dir with import library not found.'
+ print 'You have to create %r' % (str(libsdir),)
+ print 'and copy libpypy-c.lib in there, renamed to python27.lib'
+ # XXX users will complain that they cannot compile capi (cpyext)
+ # modules for windows, also embedding pypy (i.e. in cffi)
+ # will fail.
+ # Has the lib moved, was translation not 'shared', or are
+ # there no exported functions in the dll so no import
+ # library was created?
if not options.no_tk:
try:
p = pypy_c.dirpath().join('tcl85.dll')
if not p.check():
p = py.path.local.sysfind('tcl85.dll')
+ if p is None:
+ raise WindowsError("tcl85.dll not found")
tktcldir = p.dirpath().join('..').join('lib')
shutil.copytree(str(tktcldir), str(pypydir.join('tcl')))
except WindowsError:
diff --git a/rpython/config/translationoption.py b/rpython/config/translationoption.py
--- a/rpython/config/translationoption.py
+++ b/rpython/config/translationoption.py
@@ -192,6 +192,8 @@
"If true, makes an lldebug0 build", default=False,
cmdline="--lldebug0"),
StrOption("icon", "Path to the (Windows) icon to use for the executable"),
+ StrOption("libname",
+ "Windows: name and possibly location of the lib file to create"),
OptionDescription("backendopt", "Backend Optimization Options", [
# control inlining
diff --git a/rpython/translator/driver.py b/rpython/translator/driver.py
--- a/rpython/translator/driver.py
+++ b/rpython/translator/driver.py
@@ -487,13 +487,14 @@
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'))
+ # for pypy, the import library is renamed and moved to
+ # libs/python27.lib, according to the pragma in pyconfig.h
+ libname = self.config.translation.libname
+ libname = libname or soname.new(ext='lib').basename
+ libname = str(newsoname.dirpath().join(libname))
shutil.copyfile(str(soname.new(ext='lib')), libname)
self.log.info("copied: %s" % (libname,))
- # XXX TODO : replace the nonsense above with
- # ext_to_copy = ['lib', 'pdb']
+ # the pdb file goes in the same place as pypy(w).exe
ext_to_copy = ['pdb',]
for ext in ext_to_copy:
name = soname.new(ext=ext)
More information about the pypy-commit
mailing list