Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit edacea3

Browse files
author
Tarek Ziadé
committed
Merged revisions 77704,77752 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r77704 | tarek.ziade | 2010-01-23 10:23:15 +0100 (Sat, 23 Jan 2010) | 1 line taking sysconfig out of distutils ........ r77752 | tarek.ziade | 2010-01-26 00:19:56 +0100 (Tue, 26 Jan 2010) | 1 line switched the call order so this call works without suffering from issue #7774 ........
1 parent 82b8398 commit edacea3

35 files changed

Lines changed: 1197 additions & 930 deletions

Lib/distutils/ccompiler.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,58 @@
1818
from distutils.util import split_quoted, execute
1919
from distutils import log
2020

21+
_sysconfig = __import__('sysconfig')
22+
23+
def customize_compiler(compiler):
24+
"""Do any platform-specific customization of a CCompiler instance.
25+
26+
Mainly needed on Unix, so we can plug in the information that
27+
varies across Unices and is stored in Python's Makefile.
28+
"""
29+
if compiler.compiler_type == "unix":
30+
(cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \
31+
_sysconfig.get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
32+
'CCSHARED', 'LDSHARED', 'SO', 'AR',
33+
'ARFLAGS')
34+
35+
if 'CC' in os.environ:
36+
cc = os.environ['CC']
37+
if 'CXX' in os.environ:
38+
cxx = os.environ['CXX']
39+
if 'LDSHARED' in os.environ:
40+
ldshared = os.environ['LDSHARED']
41+
if 'CPP' in os.environ:
42+
cpp = os.environ['CPP']
43+
else:
44+
cpp = cc + " -E" # not always
45+
if 'LDFLAGS' in os.environ:
46+
ldshared = ldshared + ' ' + os.environ['LDFLAGS']
47+
if 'CFLAGS' in os.environ:
48+
cflags = opt + ' ' + os.environ['CFLAGS']
49+
ldshared = ldshared + ' ' + os.environ['CFLAGS']
50+
if 'CPPFLAGS' in os.environ:
51+
cpp = cpp + ' ' + os.environ['CPPFLAGS']
52+
cflags = cflags + ' ' + os.environ['CPPFLAGS']
53+
ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
54+
if 'AR' in os.environ:
55+
ar = os.environ['AR']
56+
if 'ARFLAGS' in os.environ:
57+
archiver = ar + ' ' + os.environ['ARFLAGS']
58+
else:
59+
archiver = ar + ' ' + ar_flags
60+
61+
cc_cmd = cc + ' ' + cflags
62+
compiler.set_executables(
63+
preprocessor=cpp,
64+
compiler=cc_cmd,
65+
compiler_so=cc_cmd + ' ' + ccshared,
66+
compiler_cxx=cxx,
67+
linker_so=ldshared,
68+
linker_exe=cc,
69+
archiver=archiver)
70+
71+
compiler.shared_lib_extension = so_ext
72+
2173
class CCompiler:
2274
"""Abstract base class to define the interface that must be implemented
2375
by real compiler classes. Also has some utility methods used by

Lib/distutils/command/bdist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
__revision__ = "$Id$"
77

88
import os
9+
from sysconfig import get_platform
910

1011
from distutils.core import Command
1112
from distutils.errors import DistutilsPlatformError, DistutilsOptionError
12-
from distutils.util import get_platform
1313

1414

1515
def show_formats():

Lib/distutils/command/bdist_dumb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
import os
1010

11+
from sysconfig import get_python_version, get_platform
12+
1113
from distutils.core import Command
12-
from distutils.util import get_platform
1314
from distutils.dir_util import remove_tree, ensure_relative
1415
from distutils.errors import DistutilsPlatformError
15-
from distutils.sysconfig import get_python_version
1616
from distutils import log
1717

1818
class bdist_dumb(Command):

Lib/distutils/command/bdist_wininst.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
import sys
99
import os
1010

11+
from sysconfig import get_python_version, get_platform
12+
1113
from distutils.core import Command
12-
from distutils.util import get_platform
1314
from distutils.dir_util import remove_tree
1415
from distutils.errors import DistutilsOptionError, DistutilsPlatformError
15-
from distutils.sysconfig import get_python_version
1616
from distutils import log
1717

1818
class bdist_wininst(Command):

Lib/distutils/command/build.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
__revision__ = "$Id$"
66

77
import sys, os
8+
from sysconfig import get_platform
9+
810
from distutils.core import Command
911
from distutils.errors import DistutilsOptionError
10-
from distutils.util import get_platform
1112

1213
def show_compilers():
1314
from distutils.ccompiler import show_compilers

Lib/distutils/command/build_clib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import os
2020
from distutils.core import Command
2121
from distutils.errors import DistutilsSetupError
22-
from distutils.sysconfig import customize_compiler
22+
from distutils.ccompiler import customize_compiler
2323
from distutils import log
2424

2525
def show_compilers():

Lib/distutils/command/build_ext.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
import sys, os, re
1010
from warnings import warn
1111

12+
from sysconfig import get_platform
13+
1214
from distutils.core import Command
13-
from distutils.errors import (CCompilerError, DistutilsError, CompileError,
14-
DistutilsSetupError, DistutilsPlatformError)
15-
from distutils.sysconfig import customize_compiler, get_python_version
15+
from distutils.errors import *
16+
from distutils.ccompiler import customize_compiler
1617
from distutils.dep_util import newer_group
1718
from distutils.extension import Extension
18-
from distutils.util import get_platform
19+
1920
from distutils import log
2021

2122
# this keeps compatibility from 2.3 to 2.5
@@ -172,8 +173,7 @@ def initialize_options(self):
172173
self.user = None
173174

174175
def finalize_options(self):
175-
from distutils import sysconfig
176-
176+
_sysconfig = __import__('sysconfig')
177177
self.set_undefined_options('build',
178178
('build_lib', 'build_lib'),
179179
('build_temp', 'build_temp'),
@@ -190,8 +190,8 @@ def finalize_options(self):
190190

191191
# Make sure Python's include directories (for Python.h, pyconfig.h,
192192
# etc.) are in the include search path.
193-
py_include = sysconfig.get_python_inc()
194-
plat_py_include = sysconfig.get_python_inc(plat_specific=1)
193+
py_include = _sysconfig.get_path('include')
194+
plat_py_include = _sysconfig.get_path('platinclude')
195195
if self.include_dirs is None:
196196
self.include_dirs = self.distribution.include_dirs or []
197197
if isinstance(self.include_dirs, str):
@@ -269,21 +269,21 @@ def finalize_options(self):
269269
if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")):
270270
# building third party extensions
271271
self.library_dirs.append(os.path.join(sys.prefix, "lib",
272-
"python" + get_python_version(),
272+
"python" + _sysconfig.get_python_version(),
273273
"config"))
274274
else:
275275
# building python standard extensions
276276
self.library_dirs.append('.')
277277

278278
# for extensions under Linux or Solaris with a shared Python library,
279279
# Python's library directory must be appended to library_dirs
280-
sysconfig.get_config_var('Py_ENABLE_SHARED')
280+
_sysconfig.get_config_var('Py_ENABLE_SHARED')
281281
if ((sys.platform.startswith('linux') or sys.platform.startswith('gnu')
282282
or sys.platform.startswith('sunos'))
283-
and sysconfig.get_config_var('Py_ENABLE_SHARED')):
283+
and _sysconfig.get_config_var('Py_ENABLE_SHARED')):
284284
if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")):
285285
# building third party extensions
286-
self.library_dirs.append(sysconfig.get_config_var('LIBDIR'))
286+
self.library_dirs.append(_sysconfig.get_config_var('LIBDIR'))
287287
else:
288288
# building python standard extensions
289289
self.library_dirs.append('.')
@@ -712,13 +712,13 @@ def get_ext_filename(self, ext_name):
712712
of the file from which it will be loaded (eg. "foo/bar.so", or
713713
"foo\bar.pyd").
714714
"""
715-
from distutils.sysconfig import get_config_var
715+
_sysconfig = __import__('sysconfig')
716716
ext_path = ext_name.split('.')
717717
# OS/2 has an 8 character module (extension) limit :-(
718718
if os.name == "os2":
719719
ext_path[len(ext_path) - 1] = ext_path[len(ext_path) - 1][:8]
720720
# extensions in debug_mode are named 'module_d.pyd' under windows
721-
so_ext = get_config_var('SO')
721+
so_ext = _sysconfig.get_config_var('SO')
722722
if os.name == 'nt' and self.debug:
723723
return os.path.join(*ext_path) + '_d' + so_ext
724724
return os.path.join(*ext_path) + so_ext
@@ -781,8 +781,8 @@ def get_libraries(self, ext):
781781
# Don't use the default code below
782782
return ext.libraries
783783
else:
784-
from distutils import sysconfig
785-
if sysconfig.get_config_var('Py_ENABLE_SHARED'):
784+
_sysconfig = __import__('sysconfig')
785+
if _sysconfig.get_config_var('Py_ENABLE_SHARED'):
786786
template = "python%d.%d"
787787
pythonlib = (template %
788788
(sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))

Lib/distutils/command/build_scripts.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import os, re
88
from stat import ST_MODE
9-
from distutils import sysconfig
109
from distutils.core import Command
1110
from distutils.dep_util import newer
1211
from distutils.util import convert_path, Mixin2to3
@@ -57,6 +56,7 @@ def copy_scripts(self):
5756
ie. starts with "\#!" and contains "python"), then adjust the first
5857
line to refer to the current Python interpreter as we copy.
5958
"""
59+
_sysconfig = __import__('sysconfig')
6060
self.mkpath(self.build_dir)
6161
outfiles = []
6262
updated_files = []
@@ -96,16 +96,16 @@ def copy_scripts(self):
9696
updated_files.append(outfile)
9797
if not self.dry_run:
9898
outf = open(outfile, "w")
99-
if not sysconfig.python_build:
99+
if not _sysconfig.is_python_build():
100100
outf.write("#!%s%s\n" %
101101
(self.executable,
102102
post_interp))
103103
else:
104104
outf.write("#!%s%s\n" %
105105
(os.path.join(
106-
sysconfig.get_config_var("BINDIR"),
107-
"python%s%s" % (sysconfig.get_config_var("VERSION"),
108-
sysconfig.get_config_var("EXE"))),
106+
_sysconfig.get_config_var("BINDIR"),
107+
"python%s%s" % (_sysconfig.get_config_var("VERSION"),
108+
_sysconfig.get_config_var("EXE"))),
109109
post_interp))
110110
outf.writelines(f.readlines())
111111
outf.close()

Lib/distutils/command/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from distutils.core import Command
1818
from distutils.errors import DistutilsExecError
19-
from distutils.sysconfig import customize_compiler
19+
from distutils.ccompiler import customize_compiler
2020
from distutils import log
2121

2222
LANG_EXT = {"c": ".c", "c++": ".cxx"}

0 commit comments

Comments
 (0)