Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msvc9compiler: Don't raise DistutilsPlatformError on import #81

Merged
merged 1 commit into from
Dec 18, 2021

Conversation

lazka
Copy link
Contributor

@lazka lazka commented Dec 18, 2021

It gets raised when get_build_version() returns a too low version
or when it fails to detect a MSVC version, which for example is the
case when CPython is built with gcc/clang.

In theory this module isn't needed on non-MSVC platforms, but setuptools
imports it anyway when monkey patching, which in turn makes setuptools fail.

To work around this only check the version when initialising MSVCCompiler().

This also mirrors the behaviour of the newer MSVCCompiler() (in _msvccompiler)
which also raises DistutilsPlatformError() only on initialisation in case
it can't find the right MSVC.

Part of #34

It gets raised when get_build_version() returns a too low version
or when it fails to detect a MSVC version, which for exaple is the
case when CPython is built with gcc/clang.

In theory this module isn't needed on non-MSVC platforms, but setuptools
imports it anyway when monkey patching, which in turn makes setuptools fail.

To work around this only check the version when initialising MSVCCompiler().

This also mirrors the behaviour of the newer MSVCCompiler() (in _msvccompiler)
which also raises DistutilsPlatformError() only on initialisation in case
it can't find the right MSVC.
@lazka
Copy link
Contributor Author

lazka commented Dec 18, 2021

For context, here is the error on monkey patching:

$ export SETUPTOOLS_USE_DISTUTILS=local
$ python setup.py build
Traceback (most recent call last):
  File "setup.py", line 13, in <module>
    from setuptools import Extension, setup
  File "C:/msys64/mingw64/lib/python3.8/site-packages/setuptools/__init__.py", line 241, in <module>
    monkey.patch_all()
  File "C:/msys64/mingw64/lib/python3.8/site-packages/setuptools/monkey.py", line 99, in patch_all
    patch_for_msvc_specialized_compiler()
  File "C:/msys64/mingw64/lib/python3.8/site-packages/setuptools/monkey.py", line 162, in patch_for_msvc_specialized_compiler
    patch_func(*msvc9('find_vcvarsall'))
  File "C:/msys64/mingw64/lib/python3.8/site-packages/setuptools/monkey.py", line 149, in patch_params
    mod = import_module(mod_name)
  File "C:/msys64/mingw64/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:/msys64/mingw64/lib/python3.8/site-packages/setuptools/_distutils/msvc9compiler.py", line 295, in <module>
    raise DistutilsPlatformError("VC %0.1f is not supported by this module" % VERSION)
distutils.errors.DistutilsPlatformError: VC 6.0 is not supported by this module

@jaraco
Copy link
Member

jaraco commented Dec 18, 2021

This also mirrors the behaviour of the newer MSVCCompiler()

Thanks for tracing this detail, which makes it easy to justify the change.

@jaraco jaraco merged commit dd3376e into pypa:main Dec 18, 2021
@jaraco
Copy link
Member

jaraco commented Dec 18, 2021

I wonder if this change means the module can also be collected on non-windows systems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants