Skip to content

COMP: Update to find_package(Python3)#1250

Draft
hjmjohnson wants to merge 1 commit intocommontk:masterfrom
BRAINSia:update-python-find-package
Draft

COMP: Update to find_package(Python3)#1250
hjmjohnson wants to merge 1 commit intocommontk:masterfrom
BRAINSia:update-python-find-package

Conversation

@hjmjohnson
Copy link
Copy Markdown
Contributor

@hjmjohnson hjmjohnson commented Jul 15, 2025

The FindPythonInterp and FindPythonLibs modules are removed.

These modules have been deprecated since CMake 3.12.

CMake 3.27 and above prefer to not provide the modules. This policy provides compatibility for projects that have not been ported away from them.

Projects using the FindPythonInterp and/or FindPythonLibs modules should be updated to use one of their replacements:

FindPython3
FindPython2
FindPython

@hjmjohnson hjmjohnson force-pushed the update-python-find-package branch from c31d004 to d573266 Compare July 15, 2025 19:23
@hjmjohnson hjmjohnson marked this pull request as draft July 16, 2025 16:40
@hjmjohnson hjmjohnson force-pushed the update-python-find-package branch from a62a27b to 49b8ad1 Compare August 5, 2025 17:15
@hjmjohnson hjmjohnson force-pushed the update-python-find-package branch from 49b8ad1 to 1d15689 Compare September 3, 2025 20:02
@hjmjohnson hjmjohnson force-pushed the update-python-find-package branch 2 times, most recently from 06b25e6 to 8fa4ea2 Compare October 6, 2025 15:25
@hjmjohnson hjmjohnson force-pushed the update-python-find-package branch 3 times, most recently from 3ce57f4 to 3b0419f Compare November 12, 2025 00:06
@hjmjohnson hjmjohnson force-pushed the update-python-find-package branch from 3b0419f to fbd075a Compare December 16, 2025 13:56
@hjmjohnson hjmjohnson marked this pull request as ready for review December 16, 2025 13:57
hjmjohnson added a commit to Slicer/Slicer that referenced this pull request Dec 16, 2025
DO NOT COMMIT THIS UNTIL UPSTREAM CHANGES ARE FINALIZED
commontk/CTK#1250
hjmjohnson added a commit to Slicer/Slicer that referenced this pull request Dec 16, 2025
DO NOT COMMIT THIS UNTIL UPSTREAM CHANGES ARE FINALIZED
commontk/CTK#1250
@hjmjohnson hjmjohnson force-pushed the update-python-find-package branch from fbd075a to c1cc26a Compare January 7, 2026 16:55
hjmjohnson added a commit to Slicer/Slicer that referenced this pull request Jan 7, 2026
DO NOT COMMIT THIS UNTIL UPSTREAM CHANGES ARE FINALIZED
commontk/CTK#1250
@hjmjohnson hjmjohnson force-pushed the update-python-find-package branch 3 times, most recently from d7b8d6d to 5c222f2 Compare March 19, 2026 21:22
The FindPythonInterp and FindPythonLibs modules are removed.

These modules have been deprecated since CMake 3.12.

CMake 3.27 and above prefer to not provide the modules. This policy provides
compatibility for projects that have not been ported away from them.

Projects using the FindPythonInterp and/or FindPythonLibs modules should
be updated to use one of their replacements:
    FindPython3
    FindPython2
    FindPython

Both the Interpreter and Development checks called find_package(Python3
COMPONENTS Interpreter Development REQUIRED) independently. Combine
into a single call since find_package(Python3) should request all
needed components at once to ensure version consistency.

The old bridging code set Python3_ hints from PYTHON_ variables that
are no longer populated after the FindPython3 migration. The VTK8
path was also passing Python3_EXECUTABLE under the wrong variable name.

Fix by using find_package(Python3) results directly:
- VTK8 path: pass Python3_EXECUTABLE, Python3_INCLUDE_DIRS, and the
  extracted PYTHON_LIBRARY under the old PYTHON_ variable names
- VTK9 path: pass the same values under Python3_ hint names

The superbuild export was missing Python3_INCLUDE_DIRS, Python3_LIBRARIES,
and PYTHON_EXECUTABLE. Add the modern Python3_ variables so downstream
superbuild projects using FindPython3 receive them, and re-add
PYTHON_EXECUTABLE for legacy project compatibility.

The default FindPython3 strategy (VERSION) searches all locations and
picks the newest Python3, which can find the wrong Python in
multi-version environments or when a virtualenv is active. Set
LOCATION strategy to stop at the first version found, respecting
PATH order and virtual environments.
@hjmjohnson hjmjohnson force-pushed the update-python-find-package branch from 5c222f2 to 2fa66ec Compare March 19, 2026 21:26
@hjmjohnson hjmjohnson marked this pull request as draft March 28, 2026 14:37
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.

1 participant