Author: Yusuke Tsutsumi <[email protected]>
Branch: py3.5
Changeset: r94540:b3a56b6a0940
Date: 2018-04-27 22:30 -0700
http://bitbucket.org/pypy/pypy/changeset/b3a56b6a0940/
Log: Addressing Code Review Feedback
Refactoring to move the init_posix code to a central location,
inside of sysconfigdata.
Including an improved clause for detecting if gcc is installed on
the machine, and using a correct build argument.
diff --git a/lib-python/3/distutils/sysconfig_pypy.py
b/lib-python/3/distutils/sysconfig_pypy.py
--- a/lib-python/3/distutils/sysconfig_pypy.py
+++ b/lib-python/3/distutils/sysconfig_pypy.py
@@ -63,39 +63,9 @@
def _init_posix():
"""Initialize the module as appropriate for POSIX systems."""
- so_ext = [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION][0]
-
- g = {}
- g['CC'] = "cc -pthread"
- g['CXX'] = "c++ -pthread"
- g['OPT'] = "-DNDEBUG -O2"
- g['CFLAGS'] = "-DNDEBUG -O2"
- g['CCSHARED'] = "-fPIC"
- g['LDSHARED'] = "cc -pthread -shared"
- g['EXT_SUFFIX'] = so_ext
- g['SHLIB_SUFFIX'] = ".so"
- g['SO'] = so_ext # deprecated in Python 3, for backward compatibility
- g['AR'] = "ar"
- g['ARFLAGS'] = "rc"
- g['EXE'] = ""
- g['LIBDIR'] = os.path.join(sys.prefix, 'lib')
- g['VERSION'] = get_python_version()
-
- 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()
- g['LDSHARED'] += ' -undefined dynamic_lookup'
- g['CC'] += ' -arch %s' % (arch,)
-
+ from _sysconfigdata import build_time_vars
global _config_vars
- _config_vars = g
+ _config_vars.update(build_time_vars)
def _init_nt():
@@ -221,4 +191,3 @@
from .sysconfig_cpython import (
parse_makefile, _variable_rx, expand_makefile_vars)
-
diff --git a/lib_pypy/_sysconfigdata.py b/lib_pypy/_sysconfigdata.py
--- a/lib_pypy/_sysconfigdata.py
+++ b/lib_pypy/_sysconfigdata.py
@@ -1,5 +1,6 @@
import _imp
import os
+import sys
from distutils.spawn import find_executable
so_ext = _imp.extension_suffixes()[0]
@@ -8,13 +9,40 @@
"EXT_SUFFIX": so_ext,
"SHLIB_SUFFIX": so_ext,
"SOABI": '-'.join(so_ext.split('.')[1].split('-')[:2]),
- "SO": so_ext # deprecated in Python 3, for backward compatibility
+ "SO": so_ext, # deprecated in Python 3, for backward compatibility
+ 'CC': "cc -pthread",
+ 'CXX': "c++ -pthread",
+ 'OPT': "-DNDEBUG -O2",
+ 'CFLAGS': "-DNDEBUG -O2",
+ 'CCSHARED': "-fPIC",
+ 'LDSHARED': "cc -pthread -shared",
+ 'EXT_SUFFIX': so_ext,
+ 'SHLIB_SUFFIX': ".so",
+ 'AR': "ar",
+ 'ARFLAGS': "rc",
+ 'EXE': "",
+ 'LIBDIR': os.path.join(sys.prefix, 'lib'),
+ 'VERSION': sys.version[:3]
}
-cc_compiler_path = os.path.realpath(find_executable("cc"))
-cc_compiler = os.path.basename(cc_compiler_path)
-build_time_vars["CC"] = cc_compiler
-if "gcc" in cc_compiler or "g++" in cc_compiler:
- # If we used the gnu compiler, we can safely assume we are using the gnu
- # linker
- build_time_vars["GNULD"] = "yes"
+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()
+ build_time_vars['LDSHARED'] += ' -undefined dynamic_lookup'
+ build_time_vars['CC'] += ' -arch %s' % (arch,)
+
+if find_executable("gcc"):
+ build_time_vars.update({
+ "CC": "gcc -pthread",
+ "GNULD": "yes",
+ "LDSHARED": "gcc -pthread -shared",
+ })
+ if find_executable("g++"):
+ build_time_vars["CXX"] = "g++ -pthread"
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit