From 5def4552d4a8521fe6347cdf266e99c43c5edc44 Mon Sep 17 00:00:00 2001 From: dayschan Date: Fri, 12 Sep 2025 17:47:47 +0800 Subject: [PATCH] do not source script in setup.py --- setup.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/setup.py b/setup.py index 57d80e39..78b5b20a 100644 --- a/setup.py +++ b/setup.py @@ -97,15 +97,12 @@ def write_commit_id(): version = (Path("vllm_mindspore") / "version.txt").read_text() + def _get_ascend_home_path(): - return os.environ.get("ASCEND_HOME_PATH", "/usr/local/Ascend/ascend-toolkit/latest") + if "ASCEND_HOME_PATH" not in os.environ: + os.environ["ASCEND_HOME_PATH"] = "/usr/local/Ascend/ascend-toolkit/latest" + return os.environ.get("ASCEND_HOME_PATH") -def _get_ascend_env_path(): - env_script_path = os.path.realpath(os.path.join(_get_ascend_home_path(), "..", "set_env.sh")) - if not os.path.exists(env_script_path): - raise ValueError(f"The file '{env_script_path}' is not found, " - "please make sure environment variable 'ASCEND_HOME_PATH' is set correctly.") - return env_script_path class CustomBuildExt(build_ext): ROOT_DIR = os.path.abspath(os.path.dirname(__file__)) @@ -126,11 +123,9 @@ class CustomBuildExt(build_ext): os.makedirs(BUILD_OPS_DIR, exist_ok=True) ascend_home_path = _get_ascend_home_path() - env_script_path = _get_ascend_env_path() build_extension_dir = os.path.join(BUILD_OPS_DIR, "kernel_meta", ext_name) # Combine all cmake commands into one string cmake_cmd = ( - f"source {env_script_path} && " f"cmake -S {OPS_DIR} -B {BUILD_OPS_DIR}" f" -DCMAKE_BUILD_TYPE=Release" f" -DCMAKE_INSTALL_PREFIX={os.path.join(BUILD_OPS_DIR, 'install')}" -- Gitee