Skip to content

Commit b683804

Browse files
authored
Merge pull request #5 from Doing-The-Math/rs/highsbox
substitute highsbox for highspy
2 parents ef0805e + dd10613 commit b683804

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

mip/highs.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"Python-MIP interface to the HiGHS solver."
22

3-
import glob
43
import numbers
54
import logging
65
import os.path
@@ -22,30 +21,22 @@
2221
libfile = os.environ[ENV_KEY]
2322
logger.debug("Choosing HiGHS library {libfile} via {ENV_KEY}.")
2423
else:
25-
# try library shipped with highspy packaged
26-
import highspy
24+
# Try library from highsbox, which is optional dependency.
25+
import highsbox
26+
root = highsbox.highs_dist_dir()
2727

28-
pkg_path = os.path.dirname(highspy.__file__)
29-
30-
# need library matching operating system
28+
# Need library matching operating system.
29+
# Following: PyOptInterface/src/pyoptinterface/_src/highs.py
3130
platform = sys.platform.lower()
3231
if "linux" in platform:
33-
patterns = ["highs_bindings.*.so", "_core.*.so"]
32+
libfile = os.path.join(root, "lib", "libhighs.so")
3433
elif platform.startswith("win"):
35-
patterns = ["highs_bindings.*.pyd", "_core.*.pyd"]
34+
libfile = os.path.join(root, "bin", "highs.dll")
3635
elif any(platform.startswith(p) for p in ("darwin", "macos")):
37-
patterns = ["highs_bindings.*.so", "_core.*.so"]
36+
libfile = os.path.join(root, "lib", "libhighs.dylib")
3837
else:
3938
raise NotImplementedError(f"{sys.platform} not supported!")
40-
41-
# there should only be one match
42-
matched_files = []
43-
for pattern in patterns:
44-
matched_files.extend(glob.glob(os.path.join(pkg_path, pattern)))
45-
if len(matched_files) != 1:
46-
raise FileNotFoundError(f"Could not find HiGHS library in {pkg_path}.")
47-
[libfile] = matched_files
48-
logger.debug("Choosing HiGHS library {libfile} via highspy package.")
39+
logger.debug("Choosing HiGHS library {libfile} via highsbox package.")
4940

5041
highslib = ffi.dlopen(libfile)
5142
has_highs = True

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ numpy = [
3838
"numpy==1.21.*; python_version=='3.7'"
3939
]
4040
gurobi = ["gurobipy>=8"]
41-
highs = ["highspy>=1.5.3; python_version<='3.11'"]
41+
highs = ["highsbox>=1.10.0"]
4242
test = [
4343
"pytest>=7.4",
4444
"networkx==2.8.8; python_version>='3.8'",

0 commit comments

Comments
 (0)