Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9de38bb
Mark distutils.sysconfig as deprecated
frenzymadness Oct 15, 2020
2f73368
Import global paths from sysconfig module
frenzymadness Oct 15, 2020
43d810e
Move some similar functions from distutils.sysconfig -> sysconfig
frenzymadness Oct 15, 2020
2ca4dfd
Move the rest of global variables
frenzymadness Oct 15, 2020
09f2617
Move the rest of functions to sysconfig
frenzymadness Oct 15, 2020
24e0584
Import regexes used in tests
frenzymadness Oct 16, 2020
b9ee651
Implement compatibility option for parse_makefile
frenzymadness Oct 16, 2020
12f92cf
Do not use assignment in teardown to not lose reference to global dict
frenzymadness Oct 19, 2020
7b9b0c1
Ignore DeprecationWarning in pip code in ensurepip module
frenzymadness Oct 20, 2020
6f5aa4f
Improve setUp/tearDown of UnixCCompilerTestCase
frenzymadness Oct 20, 2020
fca8adc
Improve or create setUp/tearDown methods for tests where sysconfig._C…
frenzymadness Oct 21, 2020
318428d
Rename `distutils_compat` to `keep_unresolved` and reverse the logic
frenzymadness Oct 23, 2020
6136978
Merge all import from sysconfig to one statement
frenzymadness Oct 23, 2020
e635dbd
Allow import of sysconfig when re module is not available
frenzymadness Oct 23, 2020
d8a8cf0
Add a TODO comment about PEP 632
frenzymadness Oct 23, 2020
e317db5
Mark distutils.sysconfig as deprecated in docs
frenzymadness Oct 23, 2020
17206f0
Copy docs for get_python_inc and get_python_lib from distutils.syscon…
frenzymadness Oct 23, 2020
04ef7af
Move customize_compiler back to distutils.sysconfig as it'll be remov…
frenzymadness Oct 24, 2020
6015255
Fix import of not-yet-initialized _CONFIG_VARS
frenzymadness Nov 3, 2020
abc310b
Switch global vars from regex objects to raw strings and import re on…
frenzymadness Nov 5, 2020
17aa9c4
Move get_python_lib and get_python_inc back to distutils.sysconfig
frenzymadness Nov 13, 2020
be181b6
News entry
frenzymadness Feb 15, 2021
e253a3d
Restore build_flags accidentally removed during a rebase
frenzymadness Apr 16, 2021
cd8e387
Update Doc/distutils/apiref.rst
frenzymadness Apr 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move customize_compiler back to distutils.sysconfig as it'll be remov…
…edtogether with the module.
  • Loading branch information
frenzymadness committed Apr 16, 2021
commit 04ef7af729ccc31a111728920695962ab5431d4b
75 changes: 74 additions & 1 deletion Lib/distutils/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
_findvar1_rx,
_findvar2_rx,

customize_compiler,
expand_makefile_vars,
is_python_build,
get_config_h_filename,
Expand Down Expand Up @@ -72,3 +71,77 @@ def parse_makefile(fn, g=None):
_python_build = partial(is_python_build, check_home=True)
_init_posix = partial(sysconfig_init_posix, _config_vars)
_init_nt = partial(_init_non_posix, _config_vars)


# customize_compiler is deprecated and won't be moved to another module
def customize_compiler(compiler):
"""Do any platform-specific customization of a CCompiler instance.

Mainly needed on Unix, so we can plug in the information that
varies across Unices and is stored in Python's Makefile.
"""
if compiler.compiler_type == "unix":
if sys.platform == "darwin":
# Perform first-time customization of compiler-related
# config vars on OS X now that we know we need a compiler.
# This is primarily to support Pythons from binary
# installers. The kind and paths to build tools on
# the user system may vary significantly from the system
# that Python itself was built on. Also the user OS
# version and build tools may not support the same set
# of CPU architectures for universal builds.
global _config_vars
# Use get_config_var() to ensure _config_vars is initialized.
if not get_config_var('CUSTOMIZED_OSX_COMPILER'):
import _osx_support
_osx_support.customize_compiler(_config_vars)
_config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'

(cc, cxx, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \
get_config_vars('CC', 'CXX', 'CFLAGS',
'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')

if 'CC' in os.environ:
newcc = os.environ['CC']
if (sys.platform == 'darwin'
and 'LDSHARED' not in os.environ
and ldshared.startswith(cc)):
# On OS X, if CC is overridden, use that as the default
# command for LDSHARED as well
ldshared = newcc + ldshared[len(cc):]
cc = newcc
if 'CXX' in os.environ:
cxx = os.environ['CXX']
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 = cflags + ' ' + 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']
if 'AR' in os.environ:
ar = os.environ['AR']
if 'ARFLAGS' in os.environ:
archiver = ar + ' ' + os.environ['ARFLAGS']
else:
archiver = ar + ' ' + ar_flags

cc_cmd = cc + ' ' + cflags
compiler.set_executables(
preprocessor=cpp,
compiler=cc_cmd,
compiler_so=cc_cmd + ' ' + ccshared,
compiler_cxx=cxx,
linker_so=ldshared,
linker_exe=cc,
archiver=archiver)

compiler.shared_lib_extension = shlib_suffix
73 changes: 0 additions & 73 deletions Lib/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,79 +829,6 @@ def expand_makefile_vars(s, vars):
return s


def customize_compiler(compiler):
"""Do any platform-specific customization of a CCompiler instance.

Mainly needed on Unix, so we can plug in the information that
varies across Unices and is stored in Python's Makefile.
"""
if compiler.compiler_type == "unix":
if sys.platform == "darwin":
# Perform first-time customization of compiler-related
# config vars on OS X now that we know we need a compiler.
# This is primarily to support Pythons from binary
# installers. The kind and paths to build tools on
# the user system may vary significantly from the system
# that Python itself was built on. Also the user OS
# version and build tools may not support the same set
# of CPU architectures for universal builds.
global _CONFIG_VARS
# Use get_config_var() to ensure _CONFIG_VARS is initialized.
if not get_config_var('CUSTOMIZED_OSX_COMPILER'):
import _osx_support
_osx_support.customize_compiler(_CONFIG_VARS)
_CONFIG_VARS['CUSTOMIZED_OSX_COMPILER'] = 'True'

(cc, cxx, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \
get_config_vars('CC', 'CXX', 'CFLAGS',
'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')

if 'CC' in os.environ:
newcc = os.environ['CC']
if (sys.platform == 'darwin'
and 'LDSHARED' not in os.environ
and ldshared.startswith(cc)):
# On OS X, if CC is overridden, use that as the default
# command for LDSHARED as well
ldshared = newcc + ldshared[len(cc):]
cc = newcc
if 'CXX' in os.environ:
cxx = os.environ['CXX']
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 = cflags + ' ' + 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']
if 'AR' in os.environ:
ar = os.environ['AR']
if 'ARFLAGS' in os.environ:
archiver = ar + ' ' + os.environ['ARFLAGS']
else:
archiver = ar + ' ' + ar_flags

cc_cmd = cc + ' ' + cflags
compiler.set_executables(
preprocessor=cpp,
compiler=cc_cmd,
compiler_so=cc_cmd + ' ' + ccshared,
compiler_cxx=cxx,
linker_so=ldshared,
linker_exe=cc,
archiver=archiver)

compiler.shared_lib_extension = shlib_suffix


def _print_dict(title, data):
for index, (key, value) in enumerate(sorted(data.items())):
if index == 0:
Expand Down