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

Setuptools compatibility and Windows fixes #1558

Merged
merged 4 commits into from
Sep 3, 2024

Conversation

mstimberg
Copy link
Member

This replaces msvc.msvc14_get_vc_env (the msvc module has been removed from setuptools in version 74), by distutils._msvccompiler import _get_vc_env, which appears to work as a drop-in replacement. IIUC, the setuptools.msvc added a bit of functionality for newer compilers compared to the support in distutils, but those changes have been contributed to distutils since. This is maybe not the cleanest solution (_get_vc_env is not really meant for public use), but the distutils infrastructure is meant to be used for building Python extension packages, not for generating code at runtime, so we'll always have to work around its limitations a bit.
Speaking of which, this PR also fixes a few issues that I noted during testing on my Windows VM, most importantly quoting include/library directory names.

CC @bvogginger, @neworderofjamie

Closes #1557

@neworderofjamie
Copy link

I agree that, with setuptools 74, this is probably the solution but, what if the distutils version is from before the setuptools.msvc functionality was back-ported (I'm not 100% sure what the timescale of that process was)? I was thinking of doing something like:

try:
    from setuptools.msvc import msvc14_get_vc_env as _get_vc_env
except ImportError:
    from distutils._msvccompiler import _get_vc_env

@mstimberg
Copy link
Member Author

You are right, this would be better. BTW, 0.74.1 is out, and it reverted the change to remove the msvc module, so at least builds on Linux and macOS should no longer break. It does still remove the function we used, though.

@mstimberg mstimberg merged commit 5c6d814 into master Sep 3, 2024
62 checks passed
@mstimberg mstimberg deleted the setuptools_compatibility branch September 3, 2024 11:31
@mstimberg
Copy link
Member Author

IIUC, the setuptools.msvc added a bit of functionality for newer compilers compared to the support in distutils, but those changes have been contributed to distutils since.

Just to clarify this (I misunderstood initially): the changes from setuptools weren't contributed to the standard library distutils, but to setuptools.distutils – if you import setuptools, importing distutils will actually import setuptools.distutils.

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.

brian2 import fails with latest setuptools (version 74.0.0)
2 participants