You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add the ability to declare safe tools in a cross-build environment. (#2317)
* Add the ability to declare safe tools in a cross-build environment.
* Add an xfail if cmake isn't available on the test machine.
* Placate linter regarding positional args.
* Rework test to provide more robust confirmation of safe tools.
* Remove a test skip condition that is no longer needed.
Co-authored-by: Joe Rickerby <[email protected]>
* Rename the setting to xbuild-tools.
* Add docs to clarify that xbuild-tools is transitive.
* Raise a warning if xbuild-tools isn't defined.
* Correct a bad copy-paste in the schema generator.
* .. and now fix the indentation.
* Move sentinel handling earlier into the parsing process.
* Remove serialization from tests that won't start a test suite.
---------
Co-authored-by: Joe Rickerby <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+1
Original file line number
Diff line number
Diff line change
@@ -139,6 +139,7 @@ Options
139
139
| | [`CIBW_ENVIRONMENT_PASS_LINUX`](https://cibuildwheel.pypa.io/en/stable/options/#environment-pass) | Set environment variables on the host to pass-through to the container during the build. |
140
140
| | [`CIBW_BEFORE_ALL`](https://cibuildwheel.pypa.io/en/stable/options/#before-all) | Execute a shell command on the build system before any wheels are built. |
141
141
| | [`CIBW_BEFORE_BUILD`](https://cibuildwheel.pypa.io/en/stable/options/#before-build) | Execute a shell command preparing each wheel's build |
142
+
| | [`CIBW_XBUILD_TOOLS`](https://cibuildwheel.pypa.io/en/stable/options/#xbuild-tools) | Binaries on the path that should be included in an isolated cross-build environment. |
142
143
| | [`CIBW_REPAIR_WHEEL_COMMAND`](https://cibuildwheel.pypa.io/en/stable/options/#repair-wheel-command) | Execute a shell command to repair each built wheel |
| | [`CIBW_CONTAINER_ENGINE`](https://cibuildwheel.pypa.io/en/stable/options/#container-engine) | Specify which container engine to use when building Linux wheels |
> Binaries on the path that should be included in an isolated cross-build environment.
1048
+
1049
+
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.
1050
+
1051
+
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 included in the isolated cross-build environment using `CIBW_XBUILD_TOOLS`. The binaries listed in this setting 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.
1052
+
1053
+
If you declare a tool as a cross-build tool, and that tool cannot be found in the runtime environment, an error will be raised.
1054
+
1055
+
If you do not define `CIBW_XBUILD_TOOLS`, and you build for a platform that uses a cross-platform environment, a warning will be raised. If your project does not require any cross-build tools, you can set `CIBW_XBUILD_TOOLS` to an empty list to silence this warning.
1056
+
1057
+
*Any* tool used by the build process must be included in the `CIBW_XBUILD_TOOLS` list, not just tools that cibuildwheel will invoke directly. For example, if your build invokes `cmake`, and the `cmake` script invokes `magick` to perform some image transformations, both `cmake` and `magick` must be included in your safe tools list.
1058
+
1059
+
Platform-specific environment variables are also available on platforms that use cross-platform environment isolation:<br/>
1060
+
`CIBW_XBUILD_TOOLS_IOS`
1061
+
1062
+
#### Examples
1063
+
1064
+
!!! tab examples "Environment variables"
1065
+
1066
+
```yaml
1067
+
# Allow access to the cmake and rustc binaries in the isolated cross-build environment.
1068
+
CIBW_XBUILD_TOOLS: cmake rustc
1069
+
```
1070
+
1071
+
```yaml
1072
+
# No cross-build tools are required
1073
+
CIBW_XBUILD_TOOLS:
1074
+
```
1075
+
1076
+
!!! tab examples "pyproject.toml"
1077
+
1078
+
```toml
1079
+
[tool.cibuildwheel]
1080
+
# Allow access to the cmake and rustc binaries in the isolated cross-build environment.
Copy file name to clipboardExpand all lines: docs/platforms/ios.md
+3-1
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,9 @@ iOS builds support both the `pip` and `build` build frontends. In principle, sup
57
57
58
58
## Build environment
59
59
60
-
The environment used to run builds does not inherit the full user environment - in particular, `PATH` is deliberately re-written. This is because UNIX C tooling doesn't do a great job differentiating between "macOS ARM64" and "iOS ARM64" binaries. If (for example) Homebrew is on the path when compilation commands are invoked, it's easy for a macOS version of a library to be linked into the iOS binary, rendering it unusable on iOS. To prevent this, iOS builds always force `PATH` to a "known minimal" path, that includes only the bare system utilities, plus the current user's cargo folder (to facilitate Rust builds).
60
+
The environment used to run builds does not inherit the full user environment - in particular, `PATH` is deliberately re-written. This is because UNIX C tooling doesn't do a great job differentiating between "macOS ARM64" and "iOS ARM64" binaries. If (for example) Homebrew is on the path when compilation commands are invoked, it's easy for a macOS version of a library to be linked into the iOS binary, rendering it unusable on iOS. To prevent this, iOS builds always force `PATH` to a "known minimal" path, that includes only the bare system utilities, and the iOS compiler toolchain.
61
+
62
+
If your project requires additional tools to build (such as `cmake`, `ninja`, or `rustc`), those tools must be explicitly declared as cross-build tools using [`CIBW_XBUILD_TOOLS`](../../options#xbuild-tools). *Any* tool used by the build process must be included in the `CIBW_XBUILD_TOOLS` list, not just tools that cibuildwheel will invoke directly. For example, if your build script invokes `cmake`, and the `cmake` script invokes `magick` to perform some image transformations, both `cmake` and `magick` must be included in your cross-build tools list.
0 commit comments