-
Notifications
You must be signed in to change notification settings - Fork 259
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
Add the ability to declare safe tools in a cross-build environment. #2317
base: main
Are you sure you want to change the base?
Changes from 4 commits
a64a087
471632e
598af3c
27af6e0
3f13cb5
f7b60dd
d2dcabb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ build-verbosity = 0 | |
|
||
before-all = "" | ||
before-build = "" | ||
safe-tools = [] | ||
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. 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. Having a default seemed "a bit too political" for @freakboy3742 in the previous PR if I recall correctly.
If we have a default then yes, that would have been my proposition.
I think that without a default, it'll try to build cmake & fail. 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.
My thought here is essentially "explicit is better than implicit", for a number of reasons:
That said - consider this a "strong opinion, weakly held". If y'all would prefer to go for a list of default tools, I'm happy to oblige. And the "soft failure" approach does have some upsides: it means the ultimate failure mode for iOS builds would be the same as other platforms (i.e., no cmake installed? Error when cmake is invoked). If we do add a default set, I'd suggest:
Let me know what you'd like me to do and I'll implement that.
Sure - but a build also won't work on iOS without a 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. Some good points above, thanks @freakboy3742, though I'm still undecided. My concern is mostly around people getting stuck. It's surprising to have PATH changed out by cibuildwheel, so when users hit the 'mybuildtool: command not found' error, do they even consider that cibuildwheel might have removed it from path? Or do they end up going down a debugging rabbit hole ("okay, i have to install cmake for some reason") before finding this option. On that note, if we do go the explicit opt-in route, rather than putting default symlinks at the start of path, we could put some entries at the bottom of PATH instead - these symlinks would run a program to print something helpful and error out:
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. yet another option would be to warn if no 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. @joerick Completely agreed that the PATH clearing is unusual/unexpected behavior, and the UX around this is important to get right. The idea of having a "dummy" tool is an interesting one - if I'm understanding you correctly, we'd use the "link all declared tools, error if they're missing"; with an additional layer that any "known tool" that isn't explicitly declared would be added as a dummy warning script. However, I think @mayeut's idea is even better. An iOS configuration must define 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. Ah, so many tradeoffs! Ideally, I'd rather to avoid the concerns of complicated builds polluting the user journey of simple ones.1 Most/many builds would just set
True, but only if To stick with the current train of thought, we could soften the Lets enumerate the options...
On reflection, I'm happy with (3). The other nice thing about (3), is that the warning can say that if the build succeeds, the right value is Footnotes
|
||
repair-wheel-command = "" | ||
|
||
test-command = "" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1044,6 +1044,35 @@ Platform-specific environment variables are also available:<br/> | |
[PEP 517]: https://www.python.org/dev/peps/pep-0517/ | ||
[PEP 518]: https://www.python.org/dev/peps/pep-0517/ | ||
|
||
### `CIBW_SAFE_TOOLS` {: #safe-tools} | ||
joerick marked this conversation as resolved.
Show resolved
Hide resolved
|
||
> Binaries on the path that are safe to include in an isolated cross-build environment. | ||
|
||
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. (If we do specify a default, also list it here.) |
||
When building in a cross-platform environment, it is sometimes necessary to isolate the ``PATH`` so that binaries from the build machine don't accidentally get linked into the cross-platform binary. However, this isolation process will also hide tools that might be required to build your wheel. | ||
|
||
If there are binaries present on the `PATH` when you invoke cibuildwheel, and those binaries are required to build your wheels, those binaries can be explicitly declared as "safe" using `CIBW_SAFE_TOOLS`. These binaries will be linked into an isolated location, and that isolated location will be put on the `PATH` of the isolated environment. You do not need to provide the full path to the binary - only the executable name that would be found by the shell. | ||
|
||
If you declare a tool as safe, and that tool cannot be found in the runtime environment, an error will be raised. | ||
|
||
Platform-specific environment variables are also available on platforms that use cross-platform environment isolation:<br/> | ||
`CIBW_SAFE_TOOLS_IOS` | ||
|
||
#### Examples | ||
|
||
!!! tab examples "Environment variables" | ||
|
||
```yaml | ||
# Allow access to the cmake, ninja and rustc binaries in the isolated cross-build environment. | ||
CIBW_SAFE_TOOLS: cmake ninja rustc | ||
``` | ||
|
||
!!! tab examples "pyproject.toml" | ||
|
||
```toml | ||
[tool.cibuildwheel] | ||
|
||
# Allow access to the cmake, ninja and rustc binaries in the isolated cross-build environment. | ||
safe-tools = ["cmake", "ninja", "rustc"] | ||
``` | ||
|
||
### `CIBW_REPAIR_WHEEL_COMMAND` {: #repair-wheel-command} | ||
> Execute a shell command to repair each built wheel | ||
|
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.
(if we do set a default, this would be:)
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.
I'm seeing this a bit differently.
If it's been requested in the configuration, then fail, it's a default tool then continue. (this would probably mean the default list does not initialize safe-tools but rather extends it).