Skip to content

Commit 47194df

Browse files
authored
docs: cross compile additions & authoring additions (#510)
Some docs additions. Works toward addressing scikit-build/scikit-build#1013. Signed-off-by: Henry Schreiner <[email protected]>
1 parent 9115905 commit 47194df

File tree

4 files changed

+94
-0
lines changed

4 files changed

+94
-0
lines changed

docs/changelog.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
11
# Changelog
22

3+
## Version 0.5.1
4+
5+
Features:
6+
7+
- Add `{build_type}` and `{state}` to `build-dir` by @henryiii in #504
8+
- Include 'python' dir as an auto search path by @henryiii in #499
9+
10+
Fixes:
11+
12+
- Parse CMake version strings containing '-' by @jllllll in #508
13+
- Set NumPy include directory if known by @henryiii in #482
14+
- Adapt for `setuptools_scm` 8 writing change by @henryiii in #509
15+
- (setuptools) Support `build_type` set in toml by @henryiii in #498
16+
17+
Tests and internal:
18+
19+
- Nicer nox for docs by @henryiii in #479
20+
- Some extra Ruff checks by @henryiii in #478
21+
- Packit sync by @LecrisUT in #476
22+
23+
Docs:
24+
25+
- Fix template-file with template-path by @Freed-Wu in #485
26+
- `wheel.py.api` -> `wheel.py-api` by @njzjz in #488
27+
- A single-letter change in Configuration by @wojdyr in #490
28+
- Fix typo in `SKBUILD_CMAKE_DEFINE` env var by @aloisklink in #501
29+
- Typo in Configuration by @elazarcoh in #493
30+
- Update and add discord link by @henryiii in #477
31+
- Add page on cross-compiling by @henryiii in #510
32+
333
## Version 0.5.0
434

535
Features:

docs/cmakelists.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ scikit-build-core using the `${SKBUILD}` variable. This will be defined to "2"
99
for scikit-build-core (and "1" for classic scikit-build). You can also detect
1010
the version of scikit-build-core with `${SKBUILD_CORE_VERSION}`.
1111

12+
## Accessing information
13+
14+
Scikit-build-core provides several useful variables:
15+
16+
- `${SKBUILD_PROJECT_NAME}`: The name of the project.
17+
- `${SKBUILD_PROJECT_VERSION}`: The version of the project.
18+
- `${SKBUILD_STATE}`: The run state, one of `sdist`, `wheel`, `metadata_wheel`,
19+
`editable`, or `metadata_editable`.
20+
1221
## Finding Python
1322

1423
You can directly use FindPython:
@@ -26,6 +35,14 @@ If you are making a Limited ABI / Stable API package, you'll need the
2635
`Development.SABIModule` component instead. You can use the
2736
`SKBUILD_LIMITED_API` variable to check to see if it was requested.
2837

38+
:::{warning}
39+
40+
If you want to cross-compile to Windows ARM, you'll need to use
41+
`${SKBUILD_SOABI}`, which is always correct, instead of trusting FindPython's
42+
`Python_SOABI` value.
43+
44+
:::
45+
2946
If you want to use the old, deprecated FindPythonInterp and FindPythonLibs
3047
instead, you can. Though it should be noted that FindPythonLibs requires a trick
3148
to make it work properly if a Python library is not preset (like in manylinux):

docs/crosscompile.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Cross-compiling
2+
3+
## macOS
4+
5+
### Intel to AppleSilicon
6+
7+
On macOS, AppleClang has excellent support for making Apple Silicon and
8+
Universal2 binaries (both architectures in one binary). Scikit-build-core
9+
respects `ARCHFLAGS` if `CMAKE_SYSTEM_PROCESSOR` is not in the cmake args. These
10+
values are set by cibuildwheel when cross-compiling.
11+
12+
:::{warning}
13+
14+
If you link to any binaries, they need to be Universal2, so that you get the
15+
Apple Silicon component. This means you cannot use homebrew binaries (which are
16+
always native, and not designed to be used for building portable binaries
17+
anyway). Header-only dependencies, including NumPy, do not need to be
18+
Universal2.
19+
20+
:::
21+
22+
## Windows
23+
24+
### Intel to ARM
25+
26+
Scikit-build-core respects setuptools-style `DIST_EXTRA_CONFIG`. If is set to a
27+
file, then scikit-build-core reads the `build_ext.library_dirs` paths to find
28+
the library to link to. You will also need to set `SETUPTOOLS_EXT_SUFFIX` to the
29+
correct suffix. These values are set by cibuildwheel when cross-compiling.
30+
31+
## Linux
32+
33+
It should be possible to cross-compile to Linux, but due to the challenges of
34+
getting the manylinux RHEL devtoolkit compilers, this is currently a TODO. See
35+
`py-build-cmake <https://tttapa.github.io/py-build-cmake/Cross-compilation.html>`\_
36+
for an alternative package's usage of toolchain files.
37+
38+
### Intel to Emscripten (Pyodide)
39+
40+
When using pyodide-build, Python is set up to report the cross-compiling values
41+
by setting `_PYTHON_SYSCONFIGDATA_NAME`. This causes values like `SOABI` and
42+
`EXT_SUFFIX` to be reported by `sysconfig` as the cross-compiling values.
43+
44+
This is unfortunately incorrectly stripped from the cmake wrapper pyodide uses,
45+
so FindPython will report the wrong values, but pyodide-build will rename the
46+
.so's afterwards.

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ system, allowing you to make Python modules with CMake.
2121
getting_started
2222
configuration
2323
cmakelists
24+
crosscompile
2425
migration_guide
2526
changelog
2627
```

0 commit comments

Comments
 (0)