From 64970a53f48bd61aa1954e002c6c8bf58817ec6f Mon Sep 17 00:00:00 2001 From: WangCong <543529648@qq.com> Date: Fri, 12 Dec 2025 11:11:53 +0800 Subject: [PATCH] fix pip install -e no so --- setup.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 8b0f3ab47..0f22da523 100644 --- a/setup.py +++ b/setup.py @@ -34,10 +34,15 @@ ENABLE_SPARSE = os.getenv("ENABLE_SPARSE") -def _enable_sparse() -> bool: +def enable_sparse() -> bool: return ENABLE_SPARSE is not None and ENABLE_SPARSE.lower() == "true" +def is_editable_mode() -> bool: + commands = [arg.lower() for arg in sys.argv] + return "develop" in commands or "--editable" in commands or "-e" in commands + + class CMakeExtension(Extension): def __init__(self, name: str, source_dir: str = ""): super().__init__(name, sources=[]) @@ -55,6 +60,8 @@ def run(self): def build_cmake(self, ext: CMakeExtension): build_dir = os.path.abspath(self.build_temp) install_dir = os.path.abspath(self.build_lib) + if is_editable_mode: + install_dir = ext.cmake_file_path cmake_args = [ "-DCMAKE_BUILD_TYPE=Release", @@ -62,7 +69,7 @@ def build_cmake(self, ext: CMakeExtension): f"-DCMAKE_INSTALL_PREFIX={install_dir}", ] - if _enable_sparse(): + if enable_sparse(): cmake_args += ["-DBUILD_UCM_SPARSE=ON"] match PLATFORM: