Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r60111:4b8c42f02d1c
Date: 2013-01-16 15:05 -0800
http://bitbucket.org/pypy/pypy/changeset/4b8c42f02d1c/

Log:    adapt our distutils changes from 2.7.3

diff --git a/lib-python/3.2/distutils/command/bdist_wininst.py 
b/lib-python/3.2/distutils/command/bdist_wininst.py
--- a/lib-python/3.2/distutils/command/bdist_wininst.py
+++ b/lib-python/3.2/distutils/command/bdist_wininst.py
@@ -287,7 +287,8 @@
                              bitmaplen,        # number of bytes in bitmap
                              )
         file.write(header)
-        file.write(open(arcname, "rb").read())
+        with open(arcname, "rb") as arcfile:
+            file.write(arcfile.read())
 
     def get_installer_filename(self, fullname):
         # Factored out to allow overriding in subclasses
diff --git a/lib-python/3.2/distutils/command/build_ext.py 
b/lib-python/3.2/distutils/command/build_ext.py
--- a/lib-python/3.2/distutils/command/build_ext.py
+++ b/lib-python/3.2/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, 'libs'))
+            self.library_dirs.append(os.path.join(sys.exec_prefix, 'include'))
             if self.debug:
                 self.build_temp = os.path.join(self.build_temp, "Debug")
             else:
@@ -196,8 +196,13 @@
 
             # Append the source distribution include and library directories,
             # this allows distutils on windows to work in the source tree
-            self.include_dirs.append(os.path.join(sys.exec_prefix, 'PC'))
-            if MSVC_VERSION == 9:
+            if 0:
+                # pypy has no PC directory
+                self.include_dirs.append(os.path.join(sys.exec_prefix, 'PC'))
+            if 1:
+                # pypy has no PCBuild directory
+                pass
+            elif MSVC_VERSION == 9:
                 # Use the .lib files for the correct architecture
                 if self.plat_name == 'win32':
                     suffix = ''
@@ -688,24 +693,17 @@
         shared extension.  On most platforms, this is just 'ext.libraries';
         on Windows and OS/2, we add the Python library (eg. python20.dll).
         """
-        # The python library is always needed on Windows.  For MSVC, this
-        # is redundant, since the library is mentioned in a pragma in
-        # pyconfig.h that MSVC groks.  The other Windows compilers all seem
-        # to need it mentioned explicitly, though, so that's what we do.
-        # Append '_d' to the python import library on debug builds.
+        # For PyPy, we must not add any such Python library, on any platform
+        if "__pypy__" in sys.builtin_module_names:
+            return ext.libraries
+        # The python library is always needed on Windows.
         if sys.platform == "win32":
-            from distutils.msvccompiler import MSVCCompiler
-            if not isinstance(self.compiler, MSVCCompiler):
-                template = "python%d%d"
-                if self.debug:
-                    template = template + '_d'
-                pythonlib = (template %
-                       (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
-                # don't extend ext.libraries, it may be shared with other
-                # extensions, it is a reference to the original list
-                return ext.libraries + [pythonlib]
-            else:
-                return ext.libraries
+            template = "python%d%d"
+            pythonlib = (template %
+                   (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
+            # don't extend ext.libraries, it may be shared with other
+            # extensions, it is a reference to the original list
+            return ext.libraries + [pythonlib]
         elif sys.platform == "os2emx":
             # EMX/GCC requires the python library explicitly, and I
             # believe VACPP does as well (though not confirmed) - AIM Apr01
diff --git a/lib-python/3.2/distutils/command/install.py 
b/lib-python/3.2/distutils/command/install.py
--- a/lib-python/3.2/distutils/command/install.py
+++ b/lib-python/3.2/distutils/command/install.py
@@ -65,6 +65,13 @@
         'scripts': '$base/Scripts',
         'data'   : '$base',
         },
+    'pypy': {
+        'purelib': '$base/site-packages',
+        'platlib': '$base/site-packages',
+        'headers': '$base/include',
+        'scripts': '$base/bin',
+        'data'   : '$base',
+        },
     }
 
 # user site schemes
@@ -482,6 +489,8 @@
     def select_scheme(self, name):
         """Sets the install directories by applying the install schemes."""
         # it's the caller's problem if they supply a bad name!
+        if hasattr(sys, 'pypy_version_info'):
+            name = 'pypy'
         scheme = INSTALL_SCHEMES[name]
         for key in SCHEME_KEYS:
             attrname = 'install_' + key
diff --git a/lib-python/3.2/distutils/cygwinccompiler.py 
b/lib-python/3.2/distutils/cygwinccompiler.py
--- a/lib-python/3.2/distutils/cygwinccompiler.py
+++ b/lib-python/3.2/distutils/cygwinccompiler.py
@@ -78,6 +78,9 @@
         elif msc_ver == '1500':
             # VS2008 / MSVC 9.0
             return ['msvcr90']
+        elif msc_ver == '1600':
+            # VS2010 / MSVC 10.0
+            return ['msvcr100']
         else:
             raise ValueError("Unknown MS Compiler version %s " % msc_ver)
 
diff --git a/lib-python/3.2/distutils/msvc9compiler.py 
b/lib-python/3.2/distutils/msvc9compiler.py
--- a/lib-python/3.2/distutils/msvc9compiler.py
+++ b/lib-python/3.2/distutils/msvc9compiler.py
@@ -667,6 +667,7 @@
         temp_manifest = os.path.join(
                 build_temp,
                 os.path.basename(output_filename) + ".manifest")
+        ld_args.append('/MANIFEST')
         ld_args.append('/MANIFESTFILE:' + temp_manifest)
 
     def manifest_get_embed_info(self, target_desc, ld_args):
diff --git a/lib-python/3.2/distutils/spawn.py 
b/lib-python/3.2/distutils/spawn.py
--- a/lib-python/3.2/distutils/spawn.py
+++ b/lib-python/3.2/distutils/spawn.py
@@ -56,7 +56,6 @@
 
 def _spawn_nt(cmd, search_path=1, verbose=0, dry_run=0):
     executable = cmd[0]
-    cmd = _nt_quote_args(cmd)
     if search_path:
         # either we find one or it stays the same
         executable = find_executable(executable) or executable
@@ -64,7 +63,8 @@
     if not dry_run:
         # spawn for NT requires a full path to the .exe
         try:
-            rc = os.spawnv(os.P_WAIT, executable, cmd)
+            import subprocess
+            rc = subprocess.call(cmd)
         except OSError as exc:
             # this seems to happen when the command isn't found
             raise DistutilsExecError(
diff --git a/lib-python/3.2/distutils/tests/test_install.py 
b/lib-python/3.2/distutils/tests/test_install.py
--- a/lib-python/3.2/distutils/tests/test_install.py
+++ b/lib-python/3.2/distutils/tests/test_install.py
@@ -6,7 +6,7 @@
 import unittest
 import site
 
-from test.support import captured_stdout, run_unittest
+from test.support import captured_stdout, check_impl_detail, run_unittest
 
 from distutils import sysconfig
 from distutils.command.install import install
@@ -58,14 +58,15 @@
             expected = os.path.normpath(expected)
             self.assertEqual(got, expected)
 
-        libdir = os.path.join(destination, "lib", "python")
-        check_path(cmd.install_lib, libdir)
-        check_path(cmd.install_platlib, libdir)
-        check_path(cmd.install_purelib, libdir)
-        check_path(cmd.install_headers,
-                   os.path.join(destination, "include", "python", "foopkg"))
-        check_path(cmd.install_scripts, os.path.join(destination, "bin"))
-        check_path(cmd.install_data, destination)
+        if check_impl_detail():
+            libdir = os.path.join(destination, "lib", "python")
+            check_path(cmd.install_lib, libdir)
+            check_path(cmd.install_platlib, libdir)
+            check_path(cmd.install_purelib, libdir)
+            check_path(cmd.install_headers,
+                       os.path.join(destination, "include", "python", 
"foopkg"))
+            check_path(cmd.install_scripts, os.path.join(destination, "bin"))
+            check_path(cmd.install_data, destination)
 
     def test_user_site(self):
         # test install with --user
diff --git a/lib-python/3.2/distutils/unixccompiler.py 
b/lib-python/3.2/distutils/unixccompiler.py
--- a/lib-python/3.2/distutils/unixccompiler.py
+++ b/lib-python/3.2/distutils/unixccompiler.py
@@ -122,7 +122,22 @@
                   }
 
     if sys.platform[:6] == "darwin":
+        import platform
+        if platform.machine() == 'i386':
+            if platform.architecture()[0] == '32bit':
+                arch = 'i386'
+            else:
+                arch = 'x86_64'
+        else:
+            # just a guess
+            arch = platform.machine()
         executables['ranlib'] = ["ranlib"]
+        executables['linker_so'] += ['-undefined', 'dynamic_lookup']
+
+        for k, v in executables.iteritems():
+            if v and v[0] == 'cc':
+                v += ['-arch', arch]
+
 
     # Needed for the filename generation methods provided by the base
     # class, CCompiler.  NB. whoever instantiates/uses a particular
@@ -319,7 +334,7 @@
             # On OSX users can specify an alternate SDK using
             # '-isysroot', calculate the SDK root if it is specified
             # (and use it further on)
-            cflags = sysconfig.get_config_var('CFLAGS')
+            cflags = sysconfig.get_config_var('CFLAGS') or ''
             m = re.search(r'-isysroot\s+(\S+)', cflags)
             if m is None:
                 sysroot = '/'
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to