-
-
Notifications
You must be signed in to change notification settings - Fork 638
Description
π bug report
The srcs attribute for this cc_library for os:windows is ["python3.dll", "libs/python{python_version_nodot}.lib"]. It is missing the version-specific binary, eg python311.dll.
This will result in a runtime error (python311.dll not found) in the following scenario.
- User creates a cc_binary which has
#include <Python.h>and which depends on the libpython above. - User never defines
#Py_LIMITED_ABI - User attempts to run the cc_binary
The Python.h includes the pyconfig.h, which causes msvc to attempt linking against python3xy.dll via the#pragma comment(lib, ...)mechanism. The relevant code from the cpython project is here.
https://github.com/python/cpython/blob/d610d821fd210dce63a1132c274ffdf8acc510bc/PC/pyconfig.h.in#L315-L331
I have resolved this locally by globbing *.dll into the libpython cc_library.
A similar issue occurs if the user defines #Py_DEBUG, which causes msvc to attempt linking against the debug binary python3xy_d.dll. I did not see a way to request debug binaries using the python_repository rule but if that were enabled, I think globbing *.dll would fix that case too.
Affected Rule
python_repository
Is this a regression?
Unsure.
Description
See above.
π¬ Minimal Reproduction
See above.
π₯ Exception or Error
Runtime error python3xy.dll not found
π Your Environment
Operating System:
Windows 10
Output of bazel version:
7.0.2
Rules_python version:
0.31.0
Anything else relevant?