-
Notifications
You must be signed in to change notification settings - Fork 53
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
feat: Rework CMake search path settings #880
Open
LecrisUT
wants to merge
3
commits into
scikit-build:main
Choose a base branch
from
LecrisUT:feat/ignore-prefix
base: main
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.
Open
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 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 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 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 |
---|---|---|
|
@@ -32,6 +32,7 @@ getting_started | |
configuration | ||
overrides | ||
cmakelists | ||
search_paths | ||
crosscompile | ||
migration_guide | ||
build | ||
|
This file contains 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 |
---|---|---|
@@ -0,0 +1,197 @@ | ||
# Search paths | ||
|
||
Scikit-build-core populates CMake search paths to take into account any other | ||
CMake project installed in the same environment. | ||
|
||
## `<PackageName>_ROOT` | ||
|
||
This is the most recommended interface to be used for importing dependent | ||
packages using `find_package`. This variable is populated by the dependent | ||
project's entry-point `cmake.root` or by the current project's `search.roots` | ||
option, the latter having a higher priority. | ||
|
||
To configure the `cmake.root` entry-point to export to other projects, you | ||
can use the CMake standard install paths in you `CMakeLists.txt` if you use | ||
`wheel.install-dir` option, e.g. | ||
|
||
```{code-block} cmake | ||
:caption: CMakeLists.txt | ||
:emphasize-lines: 14-16 | ||
|
||
include(CMakePackageConfigHelpers) | ||
include(GNUInstallDirs) | ||
write_basic_package_version_file( | ||
MyProjectConfigVersion.cmake | ||
VERSION ${PROJECT_VERSION} | ||
COMPATIBILITY SameMajorVersion | ||
) | ||
configure_package_config_file( | ||
cmake/MyProjectConfig.cmake.in | ||
MyProjectConfig.cmake | ||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MyProject | ||
) | ||
install(FILES | ||
${CMAKE_CURRENT_BINARY_DIR}/MyProjectConfigVersion.cmake | ||
${CMAKE_CURRENT_BINARY_DIR}/MyProjectConfig.cmake | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MyProject | ||
) | ||
``` | ||
```{code-block} toml | ||
:caption: pyproject.toml | ||
:emphasize-lines: 2,5 | ||
|
||
[tool.scikit-build] | ||
wheel.install-dir = "myproject" | ||
|
||
[project.entry-points."cmake.root"] | ||
MyProject = "myproject" | ||
``` | ||
|
||
:::{note} | ||
|
||
Scikit-build-core does not currently support dynamic entry-points population. | ||
|
||
::: | ||
|
||
With this any consuming project that depends on this would automatically work | ||
with `find_package(MyProject)` as long as it is in the `build-system.requires` | ||
list. When consuming a project, you can ignore these entry-points by setting | ||
`search.ignore_entry_point` or expand them with `search.roots`, e.g. | ||
|
||
````{tab} pyproject.toml | ||
|
||
```toml | ||
[tool.scikit-build.search] | ||
ignore_entry_point = ["MyProject"] | ||
[tool.scikit-build.search.roots] | ||
OtherProject = "/path/to/other_project" | ||
``` | ||
|
||
```` | ||
|
||
`````{tab} config-settings | ||
|
||
|
||
````{tab} pip | ||
|
||
```console | ||
$ pip install . -v --config-settings=search.ignore_entry_point="MyProject" --config-settings=search.roots.OtherProject="/path/to/other_project" | ||
``` | ||
|
||
```` | ||
|
||
````{tab} build | ||
|
||
```console | ||
$ pipx run build --wheel -Csearch.ignore_entry_point="MyProject" -Csearch.roots.OtherProject="/path/to/other_project" | ||
``` | ||
|
||
```` | ||
|
||
````{tab} cibuildwheel | ||
|
||
```toml | ||
[tool.cibuildwheel.config-settings] | ||
"search.ignore_entry_point" = ["MyProject"] | ||
"search.roots.OtherProject" = "/path/to/other_project" | ||
``` | ||
|
||
```` | ||
|
||
````` | ||
|
||
````{tab} Environment | ||
|
||
|
||
```yaml | ||
SKBUILD_SEARCH_IGNORE_ENTRY_POINT: "MyProject" | ||
SKBUILD_SEARCH_ROOTS_OtherProject: "/path/to/other_project" | ||
``` | ||
|
||
```` | ||
|
||
## `CMAKE_PREFIX_PATH` | ||
|
||
Another common search path that scikit-build-core populates is the | ||
`CMAKE_PREFIX_PATH` which is a common catch-all for all CMake search paths, | ||
e.g. `find_package`, `find_program`, `find_path`. This is populated by default | ||
with the `site-packages` folder where the project will be installed or the build | ||
isolation's `site-packages` folder. This default can be disabled by setting | ||
|
||
```toml | ||
[tool.scikit-build.search] | ||
search.use-site-packages = false | ||
``` | ||
|
||
Additionally, scikit-build-core reads the entry-point `cmake.prefix`, which you | ||
can similarly export this as | ||
|
||
``` toml | ||
[project.entry-points."cmake.prefix"] | ||
MyProject = "myproject" | ||
``` | ||
|
||
and you can similarly alter them with `search.ignore_entry_point` and | ||
`search.prefixes` | ||
|
||
````{tab} pyproject.toml | ||
|
||
```toml | ||
[tool.scikit-build.search] | ||
ignore_entry_point = ["MyProject"] | ||
prefixes = ["/path/to/prefixA", "/path/to/prefixB"] | ||
``` | ||
|
||
```` | ||
|
||
`````{tab} config-settings | ||
|
||
|
||
````{tab} pip | ||
|
||
```console | ||
$ pip install . -v --config-settings=search.ignore_entry_point="MyProject" --config-settings=search.prefixes="/path/to/prefixA;/path/to/prefixB" | ||
``` | ||
|
||
```` | ||
|
||
````{tab} build | ||
|
||
```console | ||
$ pipx run build --wheel -Csearch.ignore_entry_point="MyProject" -Csearch.prefixes="/path/to/prefixA;/path/to/prefixB" | ||
``` | ||
|
||
```` | ||
|
||
````{tab} cibuildwheel | ||
|
||
```toml | ||
[tool.cibuildwheel.config-settings] | ||
"search.ignore_entry_point" = ["MyProject"] | ||
"search.prefixes" = ["/path/to/prefixA", "/path/to/prefixB"] | ||
``` | ||
|
||
```` | ||
|
||
````` | ||
|
||
````{tab} Environment | ||
|
||
|
||
```yaml | ||
SKBUILD_SEARCH_IGNORE_ENTRY_POINT: "MyProject" | ||
SKBUILD_SEARCH_PREFIXES: "/path/to/prefixA;/path/to/prefixB" | ||
``` | ||
|
||
```` | ||
|
||
## `CMAKE_MODULE_PATH` | ||
|
||
Scikit-build-core also populates `CMAKE_MODULE_PATH` variable used to search | ||
for CMake modules using the `include()` command (if the `.cmake` suffix is | ||
omitted). | ||
|
||
This variable is populated from the entry-point `cmake.module` and the option | ||
`search.modules` similar to [`CMAKE_PREFIX_PATH`] section. | ||
|
||
[`CMAKE_PREFIX_PATH`]: #cmake-prefix-path | ||
This file contains 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 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
Oops, something went wrong.
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.
This link does indeed work, but the CI is reporting as not working 🤷