|
7 | 7 | extra_compile_args = [] |
8 | 8 | extra_link_args = [] |
9 | 9 |
|
10 | | -# if SCIPOPTDIR is not set, we assume that SCIP is installed globally |
| 10 | +# if SCIPOPTDIR is not set, try to detect conda environment, otherwise assume global installation |
11 | 11 | if not scipoptdir: |
12 | | - if platform.system() == "Darwin": |
13 | | - includedir = "/usr/local/include" |
14 | | - libdir = "/usr/local/lib" |
| 12 | + # check if we're in a conda environment |
| 13 | + conda_prefix = os.environ.get("CONDA_PREFIX", "").strip('"') |
| 14 | + |
| 15 | + if conda_prefix and os.path.exists(os.path.join(conda_prefix, "include")): |
| 16 | + includedir = os.path.join(conda_prefix, "include") |
| 17 | + libdir = os.path.join(conda_prefix, "lib") |
| 18 | + libname = "libscip" if platform.system() == "Windows" else "scip" |
| 19 | + print(f"Detected conda environment at {conda_prefix}.") |
| 20 | + print(f"Using include path {includedir}.") |
| 21 | + print(f"Using library directory {libdir}.\n") |
15 | 22 | else: |
16 | | - includedir = "." |
17 | | - libdir = "." |
18 | | - libname = "libscip" if platform.system() in ["Windows"] else "scip" |
19 | | - print("Assuming that SCIP is installed globally, because SCIPOPTDIR is undefined.\n") |
| 23 | + # fall back to global installation |
| 24 | + if platform.system() == "Darwin": |
| 25 | + includedir = "/usr/local/include" |
| 26 | + libdir = "/usr/local/lib" |
| 27 | + else: |
| 28 | + includedir = "." |
| 29 | + libdir = "." |
| 30 | + libname = "libscip" if platform.system() == "Windows" else "scip" |
| 31 | + print("Assuming that SCIP is installed globally, because SCIPOPTDIR is undefined.\n") |
20 | 32 |
|
21 | 33 | else: |
22 | 34 |
|
|
51 | 63 | else: |
52 | 64 | # assume that SCIP is installed on the system |
53 | 65 | libdir = os.path.abspath(os.path.join(scipoptdir, "lib")) |
54 | | - libname = "libscip" if platform.system() in ["Windows"] else "scip" |
| 66 | + libname = "libscip" if platform.system() == "Windows" else "scip" |
55 | 67 |
|
56 | 68 | print(f"Using include path {includedir}.") |
57 | 69 | print(f"Using SCIP library {libname} at {libdir}.\n") |
|
0 commit comments