Commit 66adb3e6 authored by Jason R. Coombs's avatar Jason R. Coombs Committed by GitHub

Merge pull request #624 from pypa/feature/msvc-discovery

Improved support for MSVC discovery
parents 94d97d07 4742d661
......@@ -2,6 +2,14 @@
CHANGES
=======
Next
----
* Pull Request #174: Add more aggressive support for
Windows SDK in msvc9compiler patch.
* Renamed ``setuptools.msvc9_support`` to
``setuptools.msvc``.
v23.2.1
-------
......
......@@ -8,11 +8,11 @@ import distutils.extension
from setuptools.extern.six.moves import map
from .dist import _get_unpatched
from . import msvc9_support
from . import msvc
_Extension = _get_unpatched(distutils.core.Extension)
msvc9_support.patch_for_specialized_compiler()
msvc.patch_for_specialized_compiler()
def _have_cython():
"""
......
This diff is collapsed.
try:
import distutils.msvc9compiler
except Exception:
pass
unpatched = dict()
def patch_for_specialized_compiler():
"""
Patch functions in distutils.msvc9compiler to use the standalone compiler
build for Python (Windows only). Fall back to original behavior when the
standalone compiler is not available.
"""
if 'distutils' not in globals():
# The module isn't available to be patched
return
if unpatched:
# Already patched
return
unpatched.update(vars(distutils.msvc9compiler))
distutils.msvc9compiler.find_vcvarsall = find_vcvarsall
distutils.msvc9compiler.query_vcvarsall = query_vcvarsall
def find_vcvarsall(version):
Reg = distutils.msvc9compiler.Reg
VC_BASE = r'Software\%sMicrosoft\DevDiv\VCForPython\%0.1f'
key = VC_BASE % ('', version)
try:
# Per-user installs register the compiler path here
productdir = Reg.get_value(key, "installdir")
except KeyError:
try:
# All-user installs on a 64-bit system register here
key = VC_BASE % ('Wow6432Node\\', version)
productdir = Reg.get_value(key, "installdir")
except KeyError:
productdir = None
if productdir:
import os
vcvarsall = os.path.join(productdir, "vcvarsall.bat")
if os.path.isfile(vcvarsall):
return vcvarsall
return unpatched['find_vcvarsall'](version)
def query_vcvarsall(version, *args, **kwargs):
try:
return unpatched['query_vcvarsall'](version, *args, **kwargs)
except distutils.errors.DistutilsPlatformError as exc:
if exc and "vcvarsall.bat" in exc.args[0]:
message = 'Microsoft Visual C++ %0.1f is required (%s).' % (version, exc.args[0])
if int(version) == 9:
# This redirection link is maintained by Microsoft.
# Contact vspython@microsoft.com if it needs updating.
raise distutils.errors.DistutilsPlatformError(
message + ' Get it from http://aka.ms/vcpython27'
)
raise distutils.errors.DistutilsPlatformError(message)
raise
"""
Tests for msvc9compiler.
Tests for msvc support module.
"""
import os
......@@ -69,7 +69,7 @@ class TestModulePatch:
def test_patched(self):
"Test the module is actually patched"
mod_name = distutils.msvc9compiler.find_vcvarsall.__module__
assert mod_name == "setuptools.msvc9_support", "find_vcvarsall unpatched"
assert mod_name == "setuptools.msvc", "find_vcvarsall unpatched"
def test_no_registry_entryies_means_nothing_found(self):
"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment