Skip to content

Commit 9a0b3ba

Browse files
authored
[bugfix] fix pip install -e no so (#508)
fix pip install -e no so
1 parent 3a0647b commit 9a0b3ba

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

setup.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,15 @@
3434
ENABLE_SPARSE = os.getenv("ENABLE_SPARSE")
3535

3636

37-
def _enable_sparse() -> bool:
37+
def enable_sparse() -> bool:
3838
return ENABLE_SPARSE is not None and ENABLE_SPARSE.lower() == "true"
3939

4040

41+
def is_editable_mode() -> bool:
42+
commands = [arg.lower() for arg in sys.argv]
43+
return "develop" in commands or "--editable" in commands or "-e" in commands
44+
45+
4146
class CMakeExtension(Extension):
4247
def __init__(self, name: str, source_dir: str = ""):
4348
super().__init__(name, sources=[])
@@ -55,14 +60,16 @@ def run(self):
5560
def build_cmake(self, ext: CMakeExtension):
5661
build_dir = os.path.abspath(self.build_temp)
5762
install_dir = os.path.abspath(self.build_lib)
63+
if is_editable_mode:
64+
install_dir = ext.cmake_file_path
5865

5966
cmake_args = [
6067
"-DCMAKE_BUILD_TYPE=Release",
6168
f"-DPYTHON_EXECUTABLE={sys.executable}",
6269
f"-DCMAKE_INSTALL_PREFIX={install_dir}",
6370
]
6471

65-
if _enable_sparse():
72+
if enable_sparse():
6673
cmake_args += ["-DBUILD_UCM_SPARSE=ON"]
6774

6875
match PLATFORM:

0 commit comments

Comments
 (0)