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 without vcruntime140 and without distutils #4101

Closed
qwenger opened this issue Nov 3, 2023 · 2 comments
Closed

MinGW without vcruntime140 and without distutils #4101

qwenger opened this issue Nov 3, 2023 · 2 comments

Comments

@qwenger
Copy link

qwenger commented Nov 3, 2023

Hi,

I maintain https://github.com/PetterS/quickjs. We target Linux, macOS and Windows. On Windows, we rely on the MinGW tooling (python setup.py build -c mingw32).

For years we have monkey-patched distutils for this to work (https://github.com/PetterS/quickjs/blob/master/setup.py#L18). If we don't, we get C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lvcruntime140.

We don't see why we would need to link with the vcruntime when building with MinGW in general, and in particular we have no use for it in quickjs.
And distutils is deprecated with removal planned for Python 3.12.

So: what is the official way to handle this situation, without vcruntime (unless you can point an actual reason for us to link it in), without using deprecated modules and without monkey-patching setuptools' internals?

Thanks in advance.

EDIT: bonus points if this official way allows us to drop setup.py completely in favor of the modern, declarative way. (setup.cfg? pyproject.toml? build.py?)

@abravalheri
Copy link
Contributor

So: what is the official way to handle this situation, without vcruntime (unless you can point an actual reason for us to link it in), without using deprecated modules and without monkey-patching setuptools' internals?

My personal opinion would be that the best course of action here would be contacting the pypa/distutils maintainers and discussing the shortcomings of the existing implementation and asking if they would accept a PR.

And distutils is deprecated with removal planned for Python 3.12.

Please note that distutils is removed from the stdlib, but it has maintenance support via the pypa/distutils repository. In turn, distutils is effectively exposed to the Python import system when you install setuptools. Of course, the recommendation is whenever possible "import stuff" from the setuptools namespace. Please have a look on this related discussion #2806 (specially these comments #2806 (comment) and #2806 (comment))

@qwenger
Copy link
Author

qwenger commented Nov 6, 2023

I wasn't at all aware of that out-of-stdlib distutils project. You're right, I'll ask over there regarding vcruntime. It looks like there's already some talk regarding MinGW compiling going on.

Closing for now, we'll see once that distutils part is fixed how far we can standardize the setuptools side in our use-case, and if needed open a new issue on that specific topic.

Thanks a lot!

@qwenger qwenger closed this as completed Nov 6, 2023
lazka added a commit to msys2-contrib/distutils that referenced this issue Jul 21, 2024
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
jaraco pushed a commit to pypa/distutils that referenced this issue Aug 2, 2024
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
* #204 (comment)

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

Fixes #204
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

No branches or pull requests

2 participants