cmake: Use any available Python_add_library command#5606
cmake: Use any available Python_add_library command#5606dannf wants to merge 2 commits intopybind:masterfrom
Conversation
python_add_library and python3_add_library are mis-cased. These commands are capitalized. Even when corrected, this code will fail if Python_FOUND is set, but Python_add_library() is not available, which appears to be the issue described here: pybind#3996 This seems to be due to a mix of FindPython and FindPython3 usage. Both Python_add_library() and Python3_add_library() support Python 3.x, so use either one. Signed-off-by: dann frazier <dann.frazier@chainguard.dev>
|
Note: I'm not a |
|
Commands in CMake are case insensitive, only variables are case sensitive. If |
|
Do you have an example of code that this fixes? I'd be curious to see it. |
TIL :)
I see - thanks! |
https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#command-invocations (Most commands are actually defined in upper case, actually, including this one) |
|
If you have an example of a broken CMakeLists.txt, I can take a look. |
Sure. Here's the entry point: I generated a cmake trace to try and understand what is going on: What I noticed there is a windy passage involving mixed |
|
I think this line: https://github.com/NVIDIA/TensorRT-LLM/blob/28fb9aacaa5a05494635194a9cbb264da9a744bd/cpp/CMakeLists.txt#L473 or https://github.com/NVIDIA/TensorRT-LLM/blob/28fb9aacaa5a05494635194a9cbb264da9a744bd/cpp/CMakeLists.txt#L431 is finding Also it should not be calling python3 before searching for it at https://github.com/NVIDIA/TensorRT-LLM/blob/5bdf997963365ff6ff167e21ab1f53631cf274eb/cpp/CMakeLists.txt#L156. |
Thanks @henryiii ! |
Description
python_add_library and python3_add_library are mis-cased. These commands are capitalized.
Even when corrected, this code will fail if Python_FOUND is set, but Python_add_library() is not available, which appears to be the issue described here:
#3996
This seems to be due to a mix of FindPython and FindPython3 usage. Both Python_add_library() and Python3_add_library() support Python 3.x, so use either one.
Suggested changelog entry: