-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
python - link statically against vc_redist #1205
base: master
Are you sure you want to change the base?
python - link statically against vc_redist #1205
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
@anthrotype this PR looks reasonable, WDYT? Basically, |
6edd536
to
5938469
Compare
An alternative solution to this problem would be using in the cibuildwheel workflow for fixing the Windows wheels. CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: delvewheel repair -w {dest_dir} {wheel} the only problem with this is the building of the win arm64 wheels, CIBW_BUILD: "cp39-win_arm64"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >-
delvewheel repair -w {dest_dir} {wheel} --add-path "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Redist\MSVC\14.40.33807\arm64\Microsoft.VC143.CRT" This is what I currently use in one of my projects with multiple precompiled libs in the wheel. |
I'm not an expert on MSVC or Windows in general, but I don't think statically linking the Microsfot C runtime library is the right thing to do for brotli, I fear this might cause other unwanted issues. |
Usually they either use mingw for compiling the wheels, statically link it, or well, leave it dangling like currently in brotli, causing issues for Windows users. |
As you don't want any static linking, then the mingw usage would have to be reworked as well, as it also uses static linking. See setup.py#L109. You're right about the static linking against vc_runtime, Microsoft themselves advice against it, and say that programs should just make the user install the corresponding runtime.... Mingw seems to bypass the issue slightly by linking against private Windows apis, but that doesn't seem like a good solution either... |
I digged a bit deeper into this. On Windows, since Python 3.9, Python versions contains the vc_runtime they were build with and put them into the python installation directory. For older Python versions, usually 3.6 to 3.8 this is not the case. So the whole vc_runtime issue only exists for Windows Python <= 3.8. |
thanks for digging deeper on this. Have you actually encountered this issue yourself? What python and windows version was that?
I'm not sure exactly which MSVC version was used to build the brotli wheels to be honest, we use this repo https://github.com/google/brotli-wheels to build and publish the wheels to pypi and over there we set up Github CI to use
3.8 just reached end of life https://devguide.python.org/versions/, maybe brotli should stop supporting those old pythons |
I encountered it once or twice some years back myself.
As brotli only depends on memset, memmove, memcpy and two internal commands from vc_runtime, this shouldn't really be an issue, as these are constant along all vc_runtime versions. From what I could gather the runtime basically just maps this to the internal Windows api of the local system, while allowing custom user hooks.
Just my two cents about this, as this is entirely up to you and the other maintainers. |
Before today, I also didn't know about the exact msvc runtime situation, especially not that Python 3.9+ ships it by default. |
This PR makes the python setup link against vc_runtime statically if msvc is used as compiler.
As cibuildwheel uses msvc on Windows, this PR solves #782 for good.
#782 is still an active issue and was closed despite it not being solved,
besides basically forcing all dependents to have to write about Windows users having to vc_redist.