-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix(cmake): find missing Python development components #6116
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
Draft
henryiii
wants to merge
1
commit into
pybind:master
Choose a base branch
from
henryiii:fix/cmake-find-missing-dev-components
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+61
−8
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,59 @@ else() | |
| set(_pybind11_quiet "") | ||
| endif() | ||
|
|
||
| if(NOT Python_FOUND AND NOT Python3_FOUND) | ||
| if(Python_FOUND) | ||
| set(_pybind11_found_python Python) | ||
| elseif(Python3_FOUND) | ||
| set(_pybind11_found_python Python3) | ||
| else() | ||
| set(_pybind11_found_python "") | ||
| endif() | ||
|
|
||
| # Development.Module support (required for manylinux) started in 3.18 | ||
| if(CMAKE_VERSION VERSION_LESS 3.18) | ||
| set(_pybind11_dev_component Development) | ||
| else() | ||
| set(_pybind11_dev_component Development.Module OPTIONAL_COMPONENTS Development.Embed) | ||
| endif() | ||
|
|
||
| # A parent project may have found Python without the development components | ||
| # pybind11 needs; ask for the missing ones, keeping the interpreter it selected. | ||
| if(_pybind11_found_python AND NOT TARGET ${_pybind11_found_python}::Module) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't check for the |
||
| if(${_pybind11_found_python}_Interpreter_FOUND) | ||
| set(_pybind11_interp_component Interpreter) | ||
| else() | ||
| set(_pybind11_interp_component "") | ||
| endif() | ||
| # Targets the parent created must not be promoted from here | ||
| set(_pybind11_new_targets "") | ||
| foreach(_pybind11_target IN ITEMS Python Module) | ||
| if(NOT TARGET ${_pybind11_found_python}::${_pybind11_target}) | ||
| list(APPEND _pybind11_new_targets ${_pybind11_target}) | ||
| endif() | ||
| endforeach() | ||
|
|
||
| set(_pybind11_global_keyword "") | ||
| if(NOT is_config AND NOT CMAKE_VERSION VERSION_LESS 3.24) | ||
| set(_pybind11_global_keyword "GLOBAL") | ||
| endif() | ||
|
|
||
| find_package( | ||
| ${_pybind11_found_python} REQUIRED | ||
| COMPONENTS ${_pybind11_interp_component} ${_pybind11_dev_component} ${_pybind11_quiet} | ||
| ${_pybind11_global_keyword}) | ||
|
|
||
| # In submodule mode, the new targets must be visible to the parent project too | ||
| if(NOT is_config AND _pybind11_global_keyword STREQUAL "") | ||
| foreach(_pybind11_target IN LISTS _pybind11_new_targets) | ||
| if(TARGET ${_pybind11_found_python}::${_pybind11_target}) | ||
| set_property(TARGET ${_pybind11_found_python}::${_pybind11_target} PROPERTY IMPORTED_GLOBAL | ||
| TRUE) | ||
| endif() | ||
| endforeach() | ||
| endif() | ||
| endif() | ||
|
|
||
| if(NOT _pybind11_found_python) | ||
| if(NOT DEFINED Python_FIND_IMPLEMENTATIONS) | ||
| set(Python_FIND_IMPLEMENTATIONS CPython PyPy) | ||
| endif() | ||
|
|
@@ -35,13 +87,6 @@ if(NOT Python_FOUND AND NOT Python3_FOUND) | |
| set(_pybind11_interp_component Interpreter) | ||
| endif() | ||
|
|
||
| # Development.Module support (required for manylinux) started in 3.18 | ||
| if(CMAKE_VERSION VERSION_LESS 3.18) | ||
| set(_pybind11_dev_component Development) | ||
| else() | ||
| set(_pybind11_dev_component Development.Module OPTIONAL_COMPONENTS Development.Embed) | ||
| endif() | ||
|
|
||
| # Callers need to be able to access Python_EXECUTABLE | ||
| set(_pybind11_global_keyword "") | ||
| if(NOT is_config AND NOT DEFINED Python_ARTIFACTS_INTERACTIVE) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is
Development.Embedreally optional? Shouldn't it be linked forpybind11::embedin any case?If so, one can simply search for
Developmentonly as the doc states: