diff --git a/setup.py b/setup.py index b80c7879c5260c013c1ab13dff402d9045e5a91f..a8be73738e72eb3e8b4ed3c413b7625b5d0cca00 100644 --- a/setup.py +++ b/setup.py @@ -131,7 +131,8 @@ class CustomBuildExt(build_ext): 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 = ( + cmake_cmd = [ + "bash", "-c", f"source {env_script_path} && " f"cmake -S {OPS_DIR} -B {BUILD_OPS_DIR}" f" -DCMAKE_BUILD_TYPE=Release" @@ -140,12 +141,12 @@ class CustomBuildExt(build_ext): f" -DMS_EXTENSION_NAME={ext_name}" f" -DASCEND_CANN_PACKAGE_PATH={ascend_home_path} && " f"cmake --build {BUILD_OPS_DIR} -j --verbose" - ) + ] try: # Run the combined cmake command - logger.info(f"Running combined CMake commands:\n{cmake_cmd}") - result = subprocess.run(cmake_cmd, cwd=self.ROOT_DIR, text=True, shell=True, capture_output=True) + logger.info(f"Running combined CMake commands:\n{' '.join(cmake_cmd[2:])}") + result = subprocess.run(cmake_cmd, cwd=self.ROOT_DIR, text=True, shell=False, capture_output=True) if result.returncode != 0: logger.info("CMake commands failed:") logger.info(result.stdout) # Print standard output