diff --git a/docs/guide/crosscompile.md b/docs/guide/crosscompile.md index 97b24531a..b558cc3af 100644 --- a/docs/guide/crosscompile.md +++ b/docs/guide/crosscompile.md @@ -52,7 +52,7 @@ correct suffix. These values are set by cibuildwheel when cross-compiling. It should be possible to cross-compile to Linux, but due to the challenges of getting the manylinux RHEL devtoolkit compilers, this is currently a TODO. See -`py-build-cmake `\_ +[py-build-cmake](https://tttapa.github.io/py-build-cmake/Cross-compilation.html) for an alternative package's usage of toolchain files. ### Intel to Emscripten (Pyodide) @@ -64,3 +64,24 @@ by setting `_PYTHON_SYSCONFIGDATA_NAME`. This causes values like `SOABI` and This is unfortunately incorrectly stripped from the cmake wrapper pyodide uses, so FindPython will report the wrong values, but pyodide-build will rename the .so's afterwards. + +## Android + +To build for Android, you'll need the following items, all of which will be +provided automatically if you use cibuildwheel: + +- A Python environment in which `sys.platform`, `sysconfig`, etc. all simulate + Android. +- A + [`CMAKE_TOOLCHAIN_FILE`](https://cmake.org/cmake/help/latest/envvar/CMAKE_TOOLCHAIN_FILE.html) + environment variable, pointing to a file which does at least the following: + - Set `CMAKE_SYSTEM_NAME`, `CMAKE_SYSTEM_PROCESSOR` and + `CMAKE_SYSTEM_VERSION`. + - Set `CMAKE_FIND_ROOT_PATH` to the location of the Python headers and + libraries. + - Set `CMAKE_CROSSCOMPILING_EMULATOR` to `/bin/sh -c [["$0" "$@"]]`. This + allows CMake to run Python in the simulated Android environment when policy + [CMP0190](https://cmake.org/cmake/help/latest/policy/CMP0190.html) is + active. +- Compiler paths and flags, either in the toolchain file or in environment + variables. diff --git a/docs/guide/faqs.md b/docs/guide/faqs.md index cdddf29a1..8e1e1706c 100644 --- a/docs/guide/faqs.md +++ b/docs/guide/faqs.md @@ -42,7 +42,7 @@ is missing some value you need, please open an issue and let us know. ## Finding Python -One common mistake when using FindPython is to forget to only request the +When using `find_package(Python ...)`, you should only request the `Development.Module` component. If you request `Development`, you will also require the `Development.Embed` component, which will require the Python libraries to be found for linking. When building a module on Unix, you do not diff --git a/tests/conftest.py b/tests/conftest.py index db9eda952..d8b6350fa 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -10,7 +10,7 @@ import sysconfig from importlib import metadata from pathlib import Path -from typing import Any, Literal, overload +from typing import TYPE_CHECKING, Any, Literal, overload import virtualenv as _virtualenv @@ -19,6 +19,8 @@ else: import tomllib +if TYPE_CHECKING: + from pytest_subprocess import FakeProcess import pytest from packaging.requirements import Requirement @@ -30,6 +32,14 @@ VIRTUALENV_VERSION = Version(metadata.version("virtualenv")) +@pytest.fixture +def fp(fp: FakeProcess) -> FakeProcess: + # For program_search._macos_binary_is_x86 + fp.register(["lipo", fp.any()], returncode=1) + fp.register(["file", fp.any()], returncode=1) + return fp + + @pytest.fixture(scope="session") def pep518_wheelhouse(tmp_path_factory: pytest.TempPathFactory) -> Path: wheelhouse = tmp_path_factory.mktemp("wheelhouse")