Author: Pawe? Piotr Przeradowski <[email protected]>
Branch: distutils-cppldflags
Changeset: r65379:e52527f04d73
Date: 2013-07-14 17:36 +0200
http://bitbucket.org/pypy/pypy/changeset/e52527f04d73/
Log: port CPython's implementation of customie_compiler, dont run split
on env vars - maybe problematic, support LDSHARED, CPPFLAGS, CFLAGS
andLDFLAGS
diff --git a/lib-python/2.7/distutils/sysconfig_pypy.py
b/lib-python/2.7/distutils/sysconfig_pypy.py
--- a/lib-python/2.7/distutils/sysconfig_pypy.py
+++ b/lib-python/2.7/distutils/sysconfig_pypy.py
@@ -12,9 +12,9 @@
import sys
import os
-import shlex
from distutils.errors import DistutilsPlatformError
+from distutils import log; log.set_verbosity(1)
PREFIX = os.path.normpath(sys.prefix)
@@ -66,6 +66,12 @@
g['SOABI'] = g['SO'].rsplit('.')[0]
g['LIBDIR'] = os.path.join(sys.prefix, 'lib')
g['CC'] = "gcc -pthread" # -pthread might not be valid on OS/X, check
+ g['OPT'] = ""
+ g['CFLAGS'] = ""
+ g['CPPFLAGS'] = ""
+ g['CCSHARED'] = '-shared -O2 -fPIC -Wimplicit'
+ g['LDSHARED'] = g['CC'] + ' -shared'
+
global _config_vars
_config_vars = g
@@ -123,21 +129,34 @@
optional C speedup components.
"""
if compiler.compiler_type == "unix":
- compiler.compiler_so.extend(['-O2', '-fPIC', '-Wimplicit'])
+ cc, opt, cflags, ccshared, ldshared = get_config_vars(
+ 'CC', 'OPT', 'CFLAGS', 'CCSHARED', 'LDSHARED')
+
compiler.shared_lib_extension = get_config_var('SO')
- if "CPPFLAGS" in os.environ:
- cppflags = shlex.split(os.environ["CPPFLAGS"])
- compiler.compiler.extend(cppflags)
- compiler.compiler_so.extend(cppflags)
- compiler.linker_so.extend(cppflags)
- if "CFLAGS" in os.environ:
- cflags = shlex.split(os.environ["CFLAGS"])
- compiler.compiler.extend(cflags)
- compiler.compiler_so.extend(cflags)
- compiler.linker_so.extend(cflags)
- if "LDFLAGS" in os.environ:
- ldflags = shlex.split(os.environ["LDFLAGS"])
- compiler.linker_so.extend(ldflags)
+
+ if 'LDSHARED' in os.environ:
+ ldshared = os.environ['LDSHARED']
+ if 'CPP' in os.environ:
+ cpp = os.environ['CPP']
+ else:
+ cpp = cc + " -E" # not always
+ if 'LDFLAGS' in os.environ:
+ ldshared = ldshared + ' ' + os.environ['LDFLAGS']
+ if 'CFLAGS' in os.environ:
+ cflags = opt + ' ' + os.environ['CFLAGS']
+ ldshared = ldshared + ' ' + os.environ['CFLAGS']
+ if 'CPPFLAGS' in os.environ:
+ cpp = cpp + ' ' + os.environ['CPPFLAGS']
+ cflags = cflags + ' ' + os.environ['CPPFLAGS']
+ ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
+
+ cc_cmd = cc + ' ' + cflags
+
+ compiler.set_executables(
+ preprocessor=cpp,
+ compiler=cc_cmd,
+ compiler_so=cc_cmd + ' ' + ccshared,
+ linker_so=ldshared)
from sysconfig_cpython import (
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit