[pypy-commit] pypy default: package dlls needed for cffi-based modules in lib_pypy

mattip pypy.commits at gmail.com
Mon Apr 1 09:33:32 EDT 2019


Author: Matti Picus <matti.picus at gmail.com>
Branch: 
Changeset: r96391:da158a6f6a35
Date: 2019-04-01 15:39 +0300
http://bitbucket.org/pypy/pypy/changeset/da158a6f6a35/

Log:	package dlls needed for cffi-based modules in lib_pypy

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
@@ -94,7 +94,7 @@
 
     if sys.platform == 'win32' and not rename_pypy_c.lower().endswith('.exe'):
         rename_pypy_c += '.exe'
-    binaries = [(pypy_c, rename_pypy_c)]
+    binaries = [(pypy_c, rename_pypy_c, None)]
 
     if (sys.platform != 'win32' and    # handled below
         not _fake and os.path.getsize(str(pypy_c)) < 500000):
@@ -106,10 +106,12 @@
         if not libpypy_c.check():
             raise PyPyCNotFound('Expected pypy to be mostly in %r, but did '
                                 'not find it' % (str(libpypy_c),))
-        binaries.append((libpypy_c, libpypy_name))
+        binaries.append((libpypy_c, libpypy_name, None))
     #
     builddir = py.path.local(options.builddir)
     pypydir = builddir.ensure(name, dir=True)
+    lib_pypy = pypydir.join('lib_pypy')
+    # do not create lib_pypy yet, it will be created by the copytree below
 
     includedir = basedir.join('include')
     shutil.copytree(str(includedir), str(pypydir.join('include')))
@@ -118,18 +120,18 @@
     if sys.platform == 'win32':
         os.environ['PATH'] = str(basedir.join('externals').join('bin')) + ';' + \
                             os.environ.get('PATH', '')
-        src,tgt = binaries[0]
+        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))
+            binaries.append((pypyw, tgt.new(purebasename=tgt.purebasename + 'w').basename, None))
             print "Picking %s" % str(pypyw)
         # Can't rename a DLL: it is always called 'libpypy-c.dll'
-        win_extras = ['libpypy-c.dll', 'sqlite3.dll']
+        win_extras = [('libpypy-c.dll', None), ('sqlite3.dll', lib_pypy)]
         if not options.no_tk:
-            win_extras += ['tcl85.dll', 'tk85.dll']
+            win_extras += [('tcl85.dll', lib_pypy), ('tk85.dll', lib_pypy)]
 
-        for extra in win_extras:
+        for extra,target_dir in win_extras:
             p = pypy_c.dirpath().join(extra)
             if not p.check():
                 p = py.path.local.sysfind(extra)
@@ -137,7 +139,7 @@
                     print "%s not found, expect trouble if this is a shared build" % (extra,)
                     continue
             print "Picking %s" % p
-            binaries.append((p, p.basename))
+            binaries.append((p, p.basename, target_dir))
         libsdir = basedir.join('libs')
         if libsdir.exists():
             print 'Picking %s (and contents)' % libsdir
@@ -169,7 +171,7 @@
                 raise MissingDependenciesError('Tk runtime')
 
     print '* Binaries:', [source.relto(str(basedir))
-                          for source, target in binaries]
+                          for source, target, target_dir in binaries]
 
     # Careful: to copy lib_pypy, copying just the hg-tracked files
     # would not be enough: there are also ctypes_config_cache/_*_cache.py.
@@ -177,15 +179,14 @@
     shutil.copytree(str(basedir.join('lib-python').join(STDLIB_VER)),
                     str(pypydir.join('lib-python').join(STDLIB_VER)),
                     ignore=ignore_patterns('.svn', 'py', '*.pyc', '*~'))
-    shutil.copytree(str(basedir.join('lib_pypy')),
-                    str(pypydir.join('lib_pypy')),
+    shutil.copytree(str(basedir.join('lib_pypy')), str(lib_pypy),
                     ignore=ignore_patterns('.svn', 'py', '*.pyc', '*~',
                                            '*_cffi.c', '*.o'))
     for file in ['README.rst',]:
         shutil.copy(str(basedir.join(file)), str(pypydir))
     for file in ['_testcapimodule.c', '_ctypes_test.c']:
         shutil.copyfile(str(basedir.join('lib_pypy', file)),
-                        str(pypydir.join('lib_pypy', file)))
+                        str(lib_pypy.join(file)))
     # Use original LICENCE file
     base_file = str(basedir.join('LICENSE'))
     with open(base_file) as fid:
@@ -201,8 +202,11 @@
     else:
         bindir = pypydir.join('bin')
         bindir.ensure(dir=True)
-    for source, target in binaries:
-        archive = bindir.join(target)
+    for source, target, target_dir in binaries:
+        if target_dir:
+            archive = target_dir.join(target)
+        else:
+            archive = bindir.join(target)
         if not _fake:
             shutil.copy(str(source), str(archive))
         else:
@@ -214,8 +218,12 @@
     try:
         os.chdir(str(builddir))
         if not _fake:
-            for source, target in binaries:
-                smartstrip(bindir.join(target), keep_debug=options.keep_debug)
+            for source, target, target_dir in binaries:
+                if target_dir:
+                    archive = target_dir.join(target)
+                else:
+                    archive = bindir.join(target)
+                smartstrip(archive, keep_debug=options.keep_debug)
         #
         if USE_ZIPFILE_MODULE:
             import zipfile


More information about the pypy-commit mailing list