Skip to content

Commit a38c8ea

Browse files
Merge branch 'master' into hybrid-node-selection
2 parents 65a3d5e + d4c6490 commit a38c8ea

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Added basic type stubs to help with IDE autocompletion and type checking.
77
- MatrixVariable comparisons (<=, >=, ==) now support numpy's broadcast feature.
88
- Added methods: getMaxDepth(), getPlungeDepth(), getLowerbound(), getCutoffbound(), getNNodeLPIterations(), getNStrongbranchLPIterations().
9+
- setup.py now automatically detects conda environments when SCIPOPTDIR is not defined.
910
### Fixed
1011
- Implemented all binary operations between MatrixExpr and GenExpr
1112
- Fixed the type of @ matrix operation result from MatrixVariable to MatrixExpr.

INSTALL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ you need to specify the install location using the environment variable
3232
`set SCIPOPTDIR=<path_to_install_dir>` (**cmd**, **Cmder**, **WSL**)\
3333
`$Env:SCIPOPTDIR = "<path_to_install_dir>"` (**powershell**)
3434

35+
**Note:** If `SCIPOPTDIR` is not set, the setup script will automatically attempt to detect a conda environment (via the `CONDA_PREFIX` environment variable) and use it if available. If no conda environment is detected, it will fall back to searching global installation paths.
36+
3537
`SCIPOPTDIR` needs to have a subdirectory `lib` that contains the
3638
library, e.g. `libscip.so` (for Linux) and a subdirectory `include` that
3739
contains the corresponding header files:

setup.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,28 @@
77
extra_compile_args = []
88
extra_link_args = []
99

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
1111
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")
1522
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")
2032

2133
else:
2234

@@ -51,7 +63,7 @@
5163
else:
5264
# assume that SCIP is installed on the system
5365
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"
5567

5668
print(f"Using include path {includedir}.")
5769
print(f"Using SCIP library {libname} at {libdir}.\n")

0 commit comments

Comments
 (0)