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

mingw: make get_msvcr() a noop + add a CI job testing MSVC Python with GCC #274

Merged
merged 3 commits into from
Aug 2, 2024

Conversation

lazka
Copy link
Contributor

@lazka lazka commented Jul 21, 2024

See the commits for details.

Fixes #204

…fault compiler

The tests currently assume everywhere that there is only one compiler per platform,
and while it would be possible to parametrize all the tests it would make things more
complex and we'd also have to decide which compiler is required for running the tests and
which one is optional etc.

To avoid all this introduce a DISTUTILS_TEST_DEFAULT_COMPILER env var which can be used
to override the default compiler type for the whole test run. This keeps the tests as is
and makes sure all tests run against the alternative compiler. Also add it to pass_env
for tox, so it gets passed to pytest, if set.

The added CI job installs an ucrt targeting GCC via MSYS2, and forces the MSVC CPython
to use it via DISTUTILS_TEST_DEFAULT_COMPILER=mingw32.
This was added back in the day to make mingw use the same CRT as CPython
(https://bugs.python.org/issue870382), but at least with newer mingw-w64 and
ucrt switching the CRT at "runtime" isn't supported anymore. To build a
compatible extension you have to use a ucrt mingw-w64 build, so things match
up and link against the same CRT.

CPython 3.5+ uses ucrt (see https://wiki.python.org/moin/WindowsCompilers), so
anything besides that is no longer relevant, which only leaves vcruntime140.

Since it's not clear what linking against vcruntime140 solves, and there have
been reports of it needing to be patched out:

* pypa/setuptools#4101
* pypa#204 (comment)

let's just make it return nothing. Keep get_msvcr() around for now to avoid breaking
code which patched it.

Fixes pypa#204
Its last use in cygwinccompiler was just removed.
@lazka
Copy link
Contributor Author

lazka commented Jul 21, 2024

(I initially made the test suite test against multiple compiler types, but that turned out to complicate things a lot, so I abandoned that approach: msys2-contrib@fa7e35b in case anyone is wondering how that would look like)

Copy link
Member

@jaraco jaraco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I have another commit I want to add to avoid re-implementing monkeypatching, but I can add that after the merge.

@jaraco jaraco merged commit de4e1be into pypa:main Aug 2, 2024
19 of 21 checks passed
@jaraco
Copy link
Member

jaraco commented Aug 2, 2024

Amended as c9781ae.

jaraco added a commit that referenced this pull request Aug 2, 2024
mingw: make get_msvcr() a noop + add a CI job testing MSVC Python with GCC
@lazka
Copy link
Contributor Author

lazka commented Aug 2, 2024

Thanks! And thanks for the improvements.

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.

Is get_msvcr still relevant?
2 participants