Skip to content

Commit b2f1b36

Browse files
committed
force conda
1 parent 2c8fe49 commit b2f1b36

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

setup.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,25 @@
1515
import numpy
1616
from setuptools import Extension, setup
1717

18-
1918
def get_boost_libraries():
19+
# Force the use of the conda-installed Boost.Python library.
20+
conda_prefix = os.environ.get("CONDA_PREFIX")
21+
if not conda_prefix:
22+
raise EnvironmentError("CONDA_PREFIX is not set. Please activate your conda environment.")
23+
if os.name == "nt":
24+
lib_dir = Path(conda_prefix) / "Library" / "lib"
25+
else:
26+
lib_dir = Path(conda_prefix) / "lib"
2027
base_lib = "boost_python"
2128
major, minor = str(sys.version_info[0]), str(sys.version_info[1])
2229
tags = [f"{major}{minor}", major, ""]
2330
mttags = ["", "-mt"]
24-
candidates = [base_lib + tag for tag in tags for mt in mttags] + [base_lib]
31+
candidates = [base_lib + tag + mt for tag in tags for mt in mttags] + [base_lib]
2532
for lib in candidates:
26-
if find_library(lib):
33+
# Check for common shared library extensions.
34+
if any((lib_dir / (lib + ext)).exists() for ext in [".so", ".dylib", ".dll", ".lib"]):
2735
return [lib]
28-
raise RuntimeError("Cannot find a suitable Boost.Python library.")
36+
raise RuntimeError("Cannot find a suitable Boost.Python library in your conda environment.")
2937

3038

3139
def get_boost_config():

0 commit comments

Comments
 (0)