Skip to content

Commit 0e1c355

Browse files
committed
Filter CMAKE_ARGS from conda-build in scikit-build
1 parent d197fad commit 0e1c355

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

setup.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import os
55
import shlex
66

7+
from typing import List
8+
79
import skbuild
810

911
__dir__ = pathlib.Path(__file__).resolve().parent
@@ -30,6 +32,15 @@ def get_version(version_file: pathlib.Path) -> str:
3032
return "{major}.{minor}.{patch}{pre}{post}{dev}".format(**version_dict)
3133

3234

35+
def get_cmake_args() -> List[str]:
36+
"""Return the list of extra CMake arguments from the environment."""
37+
cmake_args = shlex.split(os.environ.get("CMAKE_ARGS", ""))
38+
if "CONDA_BUILD" in os.environ:
39+
install_re = re.compile(r"-D\s*CMAKE_INSTALL.*")
40+
cmake_args = [a for a in cmake_args if not install_re.search(a)]
41+
return cmake_args
42+
43+
3344
install_requires = ["numpy>=1.4"]
3445
if (sys.version_info.major == 3) and (sys.version_info.minor <= 6):
3546
install_requires += ["typing_extensions"]
@@ -52,7 +63,7 @@ def get_version(version_file: pathlib.Path) -> str:
5263
# FIXME No way to pass cmake argument to scikit-build through pip (for now)
5364
# https://github.com/scikit-build/scikit-build/issues/479
5465
# So we read them from an environment variable
55-
cmake_args=shlex.split(os.environ.get("CMAKE_ARGS", "")),
66+
cmake_args=get_cmake_args(),
5667
zip_safe=False,
5768
python_requires=">=3.6",
5869
install_requires=install_requires,

0 commit comments

Comments
 (0)