Skip to content

Commit 20876f0

Browse files
author
Haroldo G. Santos
committed
Migrate from cbcbox to mipster for the bundled CBC library
cbcbox shipped CBC source builds; mipster (https://pypi.org/project/mipster/) ships self-contained, hardware-tuned wheels for Linux x86_64/aarch64, macOS x86_64/arm64, and Windows x86_64 with CPUID auto-dispatch (generic / AVX2 / Haswell / NEON variants). - Replace `cbcbox>=2.929` with `mipster>=0.2.0`. - Use `mipster.lib_path()` instead of platform-specific path joining; this returns the right shared library for the current OS and selected variant. - Drop the manual libCbc.so / libCbc-0.dll / libCbc.dylib branching. - Keep `os.add_dll_directory()` on Windows so the loader can find the sibling MinGW runtime DLLs that mipster bundles next to libmipster-N.dll. - Remove unused Cbc_get/setAllowablePercentageGap CFFI declarations (these are not exported by libmipster and were never called).
1 parent 3f03388 commit 20876f0

2 files changed

Lines changed: 11 additions & 32 deletions

File tree

mip/cbc.py

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -70,36 +70,20 @@
7070
cbclib = ffi.dlopen(libfile)
7171
os.chdir(old_dir)
7272
else:
73-
import cbcbox as _cbcbox
74-
75-
_lib_dir = _cbcbox.cbc_lib_dir()
76-
if "linux" in platform.lower():
77-
if not os_is_64_bit:
78-
raise NotImplementedError("Linux 32 bits platform not supported.")
79-
libfile = os.path.join(_lib_dir, "libCbc.so")
80-
elif platform.lower().startswith("win"):
81-
if not os_is_64_bit:
82-
raise NotImplementedError("Win32 platform not supported.")
83-
# autotools/MinGW places DLLs under bin/, not lib/
84-
_bin_dir = os.path.join(_cbcbox.cbc_dist_dir(), "bin")
85-
libfile = os.path.join(_bin_dir, "libCbc-0.dll")
86-
if not os.path.exists(libfile):
87-
raise FileNotFoundError(
88-
"libCbc-0.dll not found in cbcbox Windows distribution at"
89-
" {}. The cbcbox Windows wheel may only contain a static"
90-
" libCbc.a. A shared libCbc-0.dll is required.".format(_bin_dir)
91-
)
92-
# Python 3.8+ ignores PATH for DLL resolution; use add_dll_directory
73+
import mipster as _mipster
74+
75+
if not os_is_64_bit:
76+
raise NotImplementedError("32-bit platforms are not supported.")
77+
libfile = _mipster.lib_path()
78+
if platform.lower().startswith("win"):
79+
# Python 3.8+ ignores PATH for DLL resolution; let Windows find
80+
# any sibling DLLs (libgcc, libstdc++, libwinpthread) via
81+
# add_dll_directory on the directory holding libmipster-N.dll.
82+
_bin_dir = os.path.dirname(libfile)
9383
if hasattr(os, "add_dll_directory"):
9484
os.add_dll_directory(_bin_dir)
9585
elif _bin_dir not in os.environ.get("PATH", ""):
9686
os.environ["PATH"] = _bin_dir + ";" + os.environ["PATH"]
97-
elif platform.lower().startswith("darwin") or platform.lower().startswith(
98-
"macos"
99-
):
100-
libfile = os.path.join(_lib_dir, "libCbc.dylib")
101-
else:
102-
raise NotImplementedError("Your operating system/platform is not supported")
10387
cbclib = ffi.dlopen(libfile)
10488
has_cbc = True
10589
except Exception as e:
@@ -317,11 +301,6 @@
317301
void Cbc_setAllowableFractionGap(Cbc_Model *model,
318302
double allowedFracionGap);
319303
320-
double Cbc_getAllowablePercentageGap(Cbc_Model *model);
321-
322-
void Cbc_setAllowablePercentageGap(Cbc_Model *model,
323-
double allowedPercentageGap);
324-
325304
double Cbc_getMaximumSeconds(Cbc_Model *model);
326305
327306
void Cbc_setMaximumSeconds(Cbc_Model *model, double maxSeconds);

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ classifiers = [
3434
]
3535
dynamic = ["version"]
3636

37-
dependencies = ["cffi>=1.15", "cbcbox>=2.929"]
37+
dependencies = ["cffi>=1.15", "mipster>=0.2.0"]
3838

3939
[project.optional-dependencies]
4040
numpy = [

0 commit comments

Comments
 (0)