-
Notifications
You must be signed in to change notification settings - Fork 86
COMP: Prefer to use find_package(Python3 ) #92
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
base: patched-v3.6.1-2025-06-13-a2687828e
Are you sure you want to change the base?
COMP: Prefer to use find_package(Python3 ) #92
Conversation
The Python3 find_package is more robust and allows more control over ABI and version selections.
@jamesobutler Would you please have a look at this PR? |
Will do. I'll review in the context of the corresponding Slicer PR and then provide approvals for the chain of PRs as they get updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
The PR updates the project's CMake configuration to use the newer find_package(Python3)
API for more robust control over Python versions and ABI.
- Replace the legacy
find_package(PythonLibs)
call withfind_package(Python3 COMPONENTS Interpreter Development REQUIRED)
- Update
include_directories
to use thePython3_INCLUDE_DIRS
variable
find_package(PythonLibs REQUIRED) | ||
include_directories("${PYTHON_INCLUDE_DIR}") | ||
find_package(Python3 COMPONENTS Interpreter Development REQUIRED) | ||
include_directories("${Python3_INCLUDE_DIRS}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Instead of using the global include_directories command, link against the Python3 imported target (e.g., Python3::Python) via target_link_libraries. This automatically brings in the correct include paths and libraries, aligning with modern CMake practices.
Copilot uses AI. Check for mistakes.
@@ -53,8 +53,8 @@ endif() | |||
#----------------------------------------------------------------------------- | |||
# Python libraries | |||
|
|||
find_package(PythonLibs REQUIRED) | |||
include_directories("${PYTHON_INCLUDE_DIR}") | |||
find_package(Python3 COMPONENTS Interpreter Development REQUIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider specifying a minimum Python version (for example, find_package(Python3 3.8 COMPONENTS Interpreter Development REQUIRED)
) to enforce consistent ABI and feature availability across developer environments.
find_package(Python3 COMPONENTS Interpreter Development REQUIRED) | |
find_package(Python3 3.8 COMPONENTS Interpreter Development REQUIRED) |
Copilot uses AI. Check for mistakes.
The Python3 find_package is more robust and allows more control over ABI and version selections.