Skip to content

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

Open
wants to merge 1 commit into
base: patched-v3.6.1-2025-06-13-a2687828e
Choose a base branch
from

Conversation

hjmjohnson
Copy link

The Python3 find_package is more robust and allows more control over ABI and version selections.

The Python3 find_package is more robust and allows
more control over ABI and version selections.
@hjmjohnson
Copy link
Author

@jamesobutler Would you please have a look at this PR?

@jamesobutler
Copy link

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.

@jamesobutler jamesobutler requested a review from Copilot July 17, 2025 00:21
Copy link

@Copilot Copilot AI left a 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 with find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
  • Update include_directories to use the Python3_INCLUDE_DIRS variable

find_package(PythonLibs REQUIRED)
include_directories("${PYTHON_INCLUDE_DIR}")
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
include_directories("${Python3_INCLUDE_DIRS}")
Copy link
Preview

Copilot AI Jul 17, 2025

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)
Copy link
Preview

Copilot AI Jul 17, 2025

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.

Suggested change
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
find_package(Python3 3.8 COMPONENTS Interpreter Development REQUIRED)

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants