[pypy-commit] pypy default: remove unused distutils_platform

mattip pypy.commits at gmail.com
Wed Nov 8 13:34:04 EST 2017


Author: Matti Picus <matti.picus at gmail.com>
Branch: 
Changeset: r92976:3d3ef332444f
Date: 2017-11-08 20:28 +0200
http://bitbucket.org/pypy/pypy/changeset/3d3ef332444f/

Log:	remove unused distutils_platform

diff --git a/rpython/translator/platform/__init__.py b/rpython/translator/platform/__init__.py
--- a/rpython/translator/platform/__init__.py
+++ b/rpython/translator/platform/__init__.py
@@ -320,9 +320,7 @@
     else:
         host_factory = Cygwin64
 else:
-    # pray
-    from rpython.translator.platform.distutils_platform import DistutilsPlatform
-    host_factory = DistutilsPlatform
+    raise ValueError('unknown sys.platform "%s"', sys.platform)
 
 platform = host = host_factory()
 
@@ -335,9 +333,6 @@
     elif new_platform == 'arm':
         from rpython.translator.platform.arm import ARM
         return ARM(cc)
-    elif new_platform == 'distutils':
-        from rpython.translator.platform.distutils_platform import DistutilsPlatform
-        return DistutilsPlatform()
     else:
         raise ValueError("platform = %s" % (new_platform,))
 
diff --git a/rpython/translator/platform/distutils_platform.py b/rpython/translator/platform/distutils_platform.py
deleted file mode 100644
--- a/rpython/translator/platform/distutils_platform.py
+++ /dev/null
@@ -1,157 +0,0 @@
-import py, os, sys
-
-from rpython.translator.platform import Platform, log, CompilationError
-from rpython.translator.tool import stdoutcapture
-
-def log_spawned_cmd(spawn):
-    def spawn_and_log(cmd, *args, **kwds):
-        log.execute(' '.join(cmd))
-        return spawn(cmd, *args, **kwds)
-    return spawn_and_log
-
-CFLAGS = ['-O3']
-
-if os.name != 'nt':
-    so_ext = 'so'
-else:
-    so_ext = 'dll'
-
-class DistutilsPlatform(Platform):
-    """ This is a generic distutils platform. I hope it'll go away at some
-    point soon completely
-    """
-    name = "distutils"
-    so_ext = so_ext
-    
-    def __init__(self, cc=None):
-        self.cc = cc
-        if self.name == "distutils":
-            self.name = sys.platform
-    
-    def _ensure_correct_math(self):
-        if self.name != 'win32':
-            return # so far
-        from distutils import sysconfig
-        gcv = sysconfig.get_config_vars()
-        opt = gcv.get('OPT') # not always existent
-        if opt and '/Op' not in opt:
-            opt += '/Op'
-        gcv['OPT'] = opt
-    
-    def compile(self, cfilenames, eci, outputfilename=None, standalone=True):
-        self._ensure_correct_math()
-        self.cfilenames = cfilenames
-        if standalone:
-            ext = ''
-        else:
-            ext = so_ext
-        self.standalone = standalone
-        self.libraries = list(eci.libraries)
-        self.include_dirs = list(eci.include_dirs)
-        self.library_dirs = list(eci.library_dirs)
-        self.compile_extra = list(eci.compile_extra)
-        self.link_extra = list(eci.link_extra)
-        self.frameworks = list(eci.frameworks)
-        if not self.name in ('win32', 'darwin', 'cygwin'): # xxx
-            if 'm' not in self.libraries:
-                self.libraries.append('m')
-            self.compile_extra += CFLAGS + ['-fomit-frame-pointer']
-            if 'pthread' not in self.libraries:
-                self.libraries.append('pthread')
-            if self.name != 'sunos5': 
-                self.compile_extra += ['-pthread']
-                self.link_extra += ['-pthread']
-            else:
-                self.compile_extra += ['-pthreads']
-                self.link_extra += ['-lpthread']
-        if self.name == 'win32':
-            self.link_extra += ['/DEBUG'] # generate .pdb file
-        if self.name == 'darwin':
-            # support Fink & Darwinports
-            for s in ('/sw/', '/opt/local/'):
-                if s + 'include' not in self.include_dirs and \
-                   os.path.exists(s + 'include'):
-                    self.include_dirs.append(s + 'include')
-                if s + 'lib' not in self.library_dirs and \
-                   os.path.exists(s + 'lib'):
-                    self.library_dirs.append(s + 'lib')
-            self.compile_extra += CFLAGS + ['-fomit-frame-pointer']
-            for framework in self.frameworks:
-                self.link_extra += ['-framework', framework]
-
-        if outputfilename is None:
-            self.outputfilename = py.path.local(cfilenames[0]).new(ext=ext)
-        else:
-            self.outputfilename = py.path.local(outputfilename)
-        self.eci = eci
-        import distutils.errors
-        basename = self.outputfilename.new(ext='')
-        data = ''
-        try:
-            saved_environ = os.environ.copy()
-            c = stdoutcapture.Capture(mixed_out_err=True)
-            try:
-                self._build()
-            finally:
-                # workaround for a distutils bugs where some env vars can
-                # become longer and longer every time it is used
-                for key, value in saved_environ.items():
-                    if os.environ.get(key) != value:
-                        os.environ[key] = value
-                foutput, foutput = c.done()
-                data = foutput.read()
-                if data:
-                    fdump = basename.new(ext='errors').open("wb")
-                    fdump.write(data)
-                    fdump.close()
-        except (distutils.errors.CompileError,
-                distutils.errors.LinkError):
-            raise CompilationError('', data)
-        except:
-            print >>sys.stderr, data
-            raise
-        return self.outputfilename
-
-    def _build(self):
-        from distutils.ccompiler import new_compiler
-        from distutils import sysconfig
-        compiler = new_compiler(force=1)
-        if self.cc is not None:
-            for c in '''compiler compiler_so compiler_cxx
-                        linker_exe linker_so'''.split():
-                compiler.executables[c][0] = self.cc
-        if not self.standalone:
-            sysconfig.customize_compiler(compiler) # XXX
-        compiler.spawn = log_spawned_cmd(compiler.spawn)
-        objects = []
-        for cfile in self.cfilenames:
-            cfile = py.path.local(cfile)
-            compile_extra = self.compile_extra[:]
-
-            old = cfile.dirpath().chdir()
-            try:
-                res = compiler.compile([cfile.basename],
-                                       include_dirs=self.eci.include_dirs,
-                                       extra_preargs=compile_extra)
-                assert len(res) == 1
-                cobjfile = py.path.local(res[0])
-                assert cobjfile.check()
-                objects.append(str(cobjfile))
-            finally:
-                old.chdir()
-
-        if self.standalone:
-            cmd = compiler.link_executable
-        else:
-            cmd = compiler.link_shared_object
-        cmd(objects, str(self.outputfilename),
-            libraries=self.eci.libraries,
-            extra_preargs=self.link_extra,
-            library_dirs=self.eci.library_dirs)
-
-    def _include_dirs_for_libffi(self):
-        return ['/usr/include/libffi']
-
-    def _library_dirs_for_libffi(self):
-        return ['/usr/lib/libffi']
-
diff --git a/rpython/translator/platform/test/test_distutils.py b/rpython/translator/platform/test/test_distutils.py
deleted file mode 100644
--- a/rpython/translator/platform/test/test_distutils.py
+++ /dev/null
@@ -1,17 +0,0 @@
-
-from rpython.translator.platform.test.test_platform import TestPlatform as BasicTest
-from rpython.translator.platform.distutils_platform import DistutilsPlatform
-import py
-
-class TestDistutils(BasicTest):
-    platform = DistutilsPlatform()
-
-    def test_nice_errors(self):
-        py.test.skip("Unsupported")
-
-    def test_900_files(self):
-        py.test.skip('Makefiles not suppoerted')
-
-    def test_precompiled_headers(self):
-        py.test.skip('Makefiles not suppoerted')
-


More information about the pypy-commit mailing list