-
Notifications
You must be signed in to change notification settings - Fork 546
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
Runtime error python3xy.dll not found: Missing srcs in python_repository's libpython rule for os:windows #1823
Comments
Possibly related test failure rules_python/tests/cc/current_py_cc_libs/BUILD.bazel Lines 23 to 25 in c5c03b2
|
For the same reason as in this example, statically linking a Python extension on Windows fails when |
Similarly, any cc_library depending on @rules_python//python/cc:current_py_cc_headers and including <Python.h> will also break when compiled with -c dbg, since this also causes Python.h to attempt to link to the python3[xy]_d.lib, which is not available. |
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. |
🐞 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.rules_python/python/repositories.bzl
Lines 318 to 326 in c5c03b2
This will result in a runtime error (python311.dll not found) in the following scenario.
#include <Python.h>
and which depends on the libpython above.#Py_LIMITED_ABI
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:
Output of
bazel version
:Rules_python version:
Anything else relevant?
The text was updated successfully, but these errors were encountered: