Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Added basic type stubs to help with IDE autocompletion and type checking.
- MatrixVariable comparisons (<=, >=, ==) now support numpy's broadcast feature.
- Added methods: getMaxDepth(), getPlungeDepth(), getLowerbound(), getCutoffbound(), getNNodeLPIterations(), getNStrongbranchLPIterations().
- setup.py now automatically detects conda environments when SCIPOPTDIR is not defined.
### Fixed
- Implemented all binary operations between MatrixExpr and GenExpr
- Fixed the type of @ matrix operation result from MatrixVariable to MatrixExpr.
Expand Down
2 changes: 2 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ you need to specify the install location using the environment variable
`set SCIPOPTDIR=<path_to_install_dir>` (**cmd**, **Cmder**, **WSL**)\
`$Env:SCIPOPTDIR = "<path_to_install_dir>"` (**powershell**)

**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.

`SCIPOPTDIR` needs to have a subdirectory `lib` that contains the
library, e.g. `libscip.so` (for Linux) and a subdirectory `include` that
contains the corresponding header files:
Expand Down
30 changes: 21 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,28 @@
extra_compile_args = []
extra_link_args = []

# if SCIPOPTDIR is not set, we assume that SCIP is installed globally
# if SCIPOPTDIR is not set, try to detect conda environment, otherwise assume global installation
if not scipoptdir:
if platform.system() == "Darwin":
includedir = "/usr/local/include"
libdir = "/usr/local/lib"
# check if we're in a conda environment
conda_prefix = os.environ.get("CONDA_PREFIX", "").strip('"')

if conda_prefix and os.path.exists(os.path.join(conda_prefix, "include")):
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation only checks for the existence of the include directory but not the lib directory. This could lead to setup failures later when the library path is used. Consider also validating that os.path.join(conda_prefix, 'lib') exists before committing to use the conda environment.

Suggested change
if conda_prefix and os.path.exists(os.path.join(conda_prefix, "include")):
if (
conda_prefix
and os.path.exists(os.path.join(conda_prefix, "include"))
and os.path.exists(os.path.join(conda_prefix, "lib"))
):

Copilot uses AI. Check for mistakes.
includedir = os.path.join(conda_prefix, "include")
libdir = os.path.join(conda_prefix, "lib")
libname = "libscip" if platform.system() == "Windows" else "scip"
print(f"Detected conda environment at {conda_prefix}.")
print(f"Using include path {includedir}.")
print(f"Using library directory {libdir}.\n")
else:
includedir = "."
libdir = "."
libname = "libscip" if platform.system() in ["Windows"] else "scip"
print("Assuming that SCIP is installed globally, because SCIPOPTDIR is undefined.\n")
# fall back to global installation
if platform.system() == "Darwin":
includedir = "/usr/local/include"
libdir = "/usr/local/lib"
else:
includedir = "."
libdir = "."
libname = "libscip" if platform.system() == "Windows" else "scip"
print("Assuming that SCIP is installed globally, because SCIPOPTDIR is undefined.\n")

else:

Expand Down Expand Up @@ -51,7 +63,7 @@
else:
# assume that SCIP is installed on the system
libdir = os.path.abspath(os.path.join(scipoptdir, "lib"))
libname = "libscip" if platform.system() in ["Windows"] else "scip"
libname = "libscip" if platform.system() == "Windows" else "scip"

print(f"Using include path {includedir}.")
print(f"Using SCIP library {libname} at {libdir}.\n")
Expand Down
Loading