Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[])
Expand All @@ -55,14 +60,16 @@ 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",
f"-DPYTHON_EXECUTABLE={sys.executable}",
f"-DCMAKE_INSTALL_PREFIX={install_dir}",
]

if _enable_sparse():
if enable_sparse():
cmake_args += ["-DBUILD_UCM_SPARSE=ON"]

match PLATFORM:
Expand Down