Skip to content

Commit e27b704

Browse files
author
zhangyue
committed
revert(ascend-custom): drop pip install build-isolation accommodations
The `--unset=PYTHONPATH` in `add_custom_command` and the `CMAKE_EXE` forwarding in `build.sh` existed solely so `pip install -e .[dev]` (default build-isolation) could drive `build.sh` on Ascend. Drop both and require `--no-build-isolation` for Ascend installs — the official workflow. The `add_custom_command` driver, `BUILD_ASCEND_CUSTOM` gate, and `detect_soc.cmake` helper are unrelated to build isolation and stay.
1 parent 08a130a commit e27b704

2 files changed

Lines changed: 13 additions & 22 deletions

File tree

src/CMakeLists.txt

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -269,26 +269,24 @@ if(WITH_ASCEND)
269269
"${CMAKE_CURRENT_SOURCE_DIR}/ascend/custom/build.sh")
270270

271271
# Scrub env inherited from the outer `scikit-build-core` invocation
272-
# before handing control to `build.sh`:
273-
# * `CMAKE_GENERATOR` / `CMAKE_EXPORT_COMPILE_COMMANDS` leaking
274-
# into the inner `cmake` change the path format passed to
275-
# `ninja`'s `_host_cpp` rule and re-trigger the `CANN`
276-
# `extract_host_stub.py` `KeyError` (`/./workspace/...`) that
277-
# standalone `build.sh` avoids.
278-
# * `PYTHONPATH` from `pip`'s build-isolation overlay makes the
279-
# child `python3` skip the system `site-packages` — child
280-
# `cmake` modules that `import torch` (`config_envs.cmake`)
281-
# then fail with `ModuleNotFoundError` even though `torch` is
282-
# installed.
272+
# before handing control to `build.sh`: `CMAKE_GENERATOR` /
273+
# `CMAKE_EXPORT_COMPILE_COMMANDS` leaking into the inner `cmake`
274+
# change the path format passed to `ninja`'s `_host_cpp` rule and
275+
# re-trigger the `CANN` `extract_host_stub.py` `KeyError`
276+
# (`/./workspace/...`) that standalone `build.sh` avoids.
277+
#
278+
# `pip install` MUST be invoked with `--no-build-isolation` on
279+
# Ascend; otherwise pip's build-isolation overlay shadows system
280+
# `torch` (via `PYTHONPATH`) and the inner `cmake`'s
281+
# `import torch` in `config_envs.cmake` fails with
282+
# `ModuleNotFoundError`.
283283
add_custom_command(
284284
OUTPUT ${_custom_lib}
285285
COMMAND ${CMAKE_COMMAND} -E env
286286
--unset=CMAKE_GENERATOR
287287
--unset=CMAKE_EXPORT_COMPILE_COMMANDS
288288
--unset=CMAKE_BUILD_PARALLEL_LEVEL
289-
--unset=PYTHONPATH
290289
"BUILD_DIR=${_custom_build_dir}"
291-
"CMAKE_EXE=${CMAKE_COMMAND}"
292290
bash ${CMAKE_CURRENT_SOURCE_DIR}/ascend/custom/build.sh ${SOC_VERSION}
293291
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ascend/custom
294292
DEPENDS ${_custom_srcs}

src/ascend/custom/build.sh

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ set -e
99

1010
SOC_VERSION="${1:-Ascend910_9382}"
1111

12-
# Use the same `cmake` the caller resolved (default: first `cmake` on
13-
# PATH). The outer `src/CMakeLists.txt` forwards `${CMAKE_COMMAND}`
14-
# via `CMAKE_EXE` so the child build doesn't accidentally pick up the
15-
# PyPI `cmake` shim whose Python package only exists in `pip`'s
16-
# build-isolation overlay.
17-
CMAKE_EXE="${CMAKE_EXE:-cmake}"
18-
1912
# Detect CANN toolkit path.
2013
_CANN_TOOLKIT_INSTALL_PATH=$(grep "Toolkit_InstallPath" /etc/Ascend/ascend_cann_install.info | awk -F'=' '{print $2}')
2114
source "${_CANN_TOOLKIT_INSTALL_PATH}/set_env.sh"
@@ -32,14 +25,14 @@ OUTPUT_DIR="${BUILD_DIR}/output"
3225
rm -rf "${BUILD_DIR}"
3326
mkdir -p "${BUILD_DIR}" "${OUTPUT_DIR}"
3427

35-
"${CMAKE_EXE}" \
28+
cmake \
3629
-DASCEND_HOME_PATH="${ASCEND_HOME_PATH}" \
3730
-DASCEND_INCLUDE_DIR="${ASCEND_INCLUDE_DIR}" \
3831
-DSOC_VERSION="${SOC_VERSION}" \
3932
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY="${OUTPUT_DIR}" \
4033
-B "${BUILD_DIR}" \
4134
-S "${SCRIPT_DIR}"
4235

43-
"${CMAKE_EXE}" --build "${BUILD_DIR}" -j 16
36+
cmake --build "${BUILD_DIR}" -j 16
4437

4538
echo "Build complete. Output: ${OUTPUT_DIR}"

0 commit comments

Comments
 (0)