Skip to content

Commit 0d4e71f

Browse files
committed
executorch: install torch at build time, disable PEP 517 isolation
CMake's find_package_torch_headers/get_torch_base_path resolves torch by running `import torch` in the same interpreter running the build backend. torch is a runtime dependency (setup.py), not declared in [build-system].requires, so pip's isolated build venv never has it and CMake configure fails with AttributeError: 'NoneType' object has no attribute 'submodule_search_locations'. Preinstall build-system.requires plus torch in CIBW_BEFORE_BUILD and disable isolation via CIBW_BUILD_FRONTEND, mirroring the same pattern already used in build-torchaudio.yml and build-torchcodec.yml.
1 parent 53206a2 commit 0d4e71f

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎.github/workflows/build-executorch.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,18 @@ jobs:
165165
# build dependency; its own CMake bootstrap needs OpenSSL's dev
166166
# headers to find libcrypto.
167167
CIBW_BEFORE_ALL_LINUX: dnf -y install openssl-devel
168+
# get_torch_base_path (tools/cmake/Utils.cmake) runs `import torch` in
169+
# the same interpreter as the build backend to add it to
170+
# CMAKE_PREFIX_PATH, but torch is only a runtime dependency
171+
# (setup.py), not a build-system.requires entry, so PEP 517 isolation
172+
# hides it from that interpreter. Preinstall build-system.requires
173+
# plus torch and turn isolation off (mirrors build-torchaudio.yml /
174+
# build-torchcodec.yml).
175+
CIBW_BUILD_FRONTEND: "pip; args: --no-build-isolation"
176+
CIBW_BEFORE_BUILD: >-
177+
pip install "cmake>=3.24,<4.0.0" "packaging>=24.2" pyyaml
178+
"setuptools>=77.0.3" wheel zstd certifi &&
179+
pip install --only-binary=:all: "torch>=2.13.0a0"
168180
CIBW_ENVIRONMENT: >-
169181
CMAKE_BUILD_PARALLEL_LEVEL=8
170182
PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/

0 commit comments

Comments
 (0)