Skip to content

Commit

Permalink
Merge pull request #2653 from pypa/distutils-refresh
Browse files Browse the repository at this point in the history
Distutils refresh
  • Loading branch information
jaraco committed May 4, 2021
2 parents 6fcad30 + be2d138 commit c492876
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
1 change: 1 addition & 0 deletions changelog.d/2653.change.rst
@@ -0,0 +1 @@
Incorporated assorted changes from pypa/distutils.
2 changes: 1 addition & 1 deletion setuptools/_distutils/_msvccompiler.py
Expand Up @@ -248,7 +248,7 @@ def initialize(self, plat_name=None):
# Future releases of Python 3.x will include all past
# versions of vcruntime*.dll for compatibility.
self.compile_options = [
'/nologo', '/Ox', '/W3', '/GL', '/DNDEBUG', '/MD'
'/nologo', '/O2', '/W3', '/GL', '/DNDEBUG', '/MD'
]

self.compile_options_debug = [
Expand Down
7 changes: 7 additions & 0 deletions setuptools/_distutils/ccompiler.py
Expand Up @@ -792,13 +792,20 @@ def has_function(self, funcname, includes=None, include_dirs=None,
objects = self.compile([fname], include_dirs=include_dirs)
except CompileError:
return False
finally:
os.remove(fname)

try:
self.link_executable(objects, "a.out",
libraries=libraries,
library_dirs=library_dirs)
except (LinkError, TypeError):
return False
else:
os.remove("a.out")
finally:
for fn in objects:
os.remove(fn)
return True

def find_library_file (self, dirs, lib, debug=0):
Expand Down
4 changes: 2 additions & 2 deletions setuptools/_distutils/msvc9compiler.py
Expand Up @@ -399,13 +399,13 @@ def initialize(self, plat_name=None):

self.preprocess_options = None
if self.__arch == "x86":
self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3',
self.compile_options = [ '/nologo', '/O2', '/MD', '/W3',
'/DNDEBUG']
self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3',
'/Z7', '/D_DEBUG']
else:
# Win64
self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GS-' ,
self.compile_options = [ '/nologo', '/O2', '/MD', '/W3', '/GS-' ,
'/DNDEBUG']
self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/GS-',
'/Z7', '/D_DEBUG']
Expand Down
4 changes: 2 additions & 2 deletions setuptools/_distutils/msvccompiler.py
Expand Up @@ -283,13 +283,13 @@ def initialize(self):

self.preprocess_options = None
if self.__arch == "Intel":
self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GX' ,
self.compile_options = [ '/nologo', '/O2', '/MD', '/W3', '/GX' ,
'/DNDEBUG']
self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/GX',
'/Z7', '/D_DEBUG']
else:
# Win64
self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GS-' ,
self.compile_options = [ '/nologo', '/O2', '/MD', '/W3', '/GS-' ,
'/DNDEBUG']
self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/GS-',
'/Z7', '/D_DEBUG']
Expand Down
16 changes: 10 additions & 6 deletions setuptools/_distutils/spawn.py
Expand Up @@ -40,7 +40,7 @@ def spawn(cmd, search_path=1, verbose=0, dry_run=0, env=None):
# in, protect our %-formatting code against horrible death
cmd = list(cmd)

log.info(' '.join(cmd))
log.info(subprocess.list2cmdline(cmd))
if dry_run:
return

Expand All @@ -60,13 +60,17 @@ def spawn(cmd, search_path=1, verbose=0, dry_run=0, env=None):
if _cfg_target:
_cfg_target_split = [int(x) for x in _cfg_target.split('.')]
if _cfg_target:
# ensure that the deployment target of build process is not less
# than that used when the interpreter was built. This ensures
# extension modules are built with correct compatibility values
# Ensure that the deployment target of the build process is not
# less than 10.3 if the interpreter was built for 10.3 or later.
# This ensures extension modules are built with correct
# compatibility values, specifically LDSHARED which can use
# '-undefined dynamic_lookup' which only works on >= 10.3.
cur_target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', _cfg_target)
if _cfg_target_split > [int(x) for x in cur_target.split('.')]:
cur_target_split = [int(x) for x in cur_target.split('.')]
if _cfg_target_split[:2] >= [10, 3] and cur_target_split[:2] < [10, 3]:
my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: '
'now "%s" but "%s" during configure'
'now "%s" but "%s" during configure;'
'must use 10.3 or later'
% (cur_target, _cfg_target))
raise DistutilsPlatformError(my_msg)
env.update(MACOSX_DEPLOYMENT_TARGET=cur_target)
Expand Down

0 comments on commit c492876

Please sign in to comment.