-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
What version of OR-Tools and what language are you using?
Version: Latest (git clone of stable branch)
Language: Attempting to build Python bindings
Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)
N/A
What operating system (Linux, Windows, ...) and version?
OpenBSD-current
What did you do?
Steps to reproduce the behavior:
$ git clone --depth=1 https://github.com/google/or-tools.git# pkg_add lzlib abseil-cpp protobuf eigen3 re2- Build COIN-OR dependencies:
$ for dep in CoinUtils Osi Clp Cgl Cbc
do git clone --depth=1 https://github.com/coin-or/$dep $dep
done
$ for dep in CoinUtils Osi Clp Cgi
do cd $dep ; ./configure -C --prefix=/home/myuser/coin --exec-prefix=/home/myuser/coin ;
make && make install
clean
cd ..
doneThe Cbc repository includes a compilation error on BSD systems that must be corrected. Replace the reinterpret_cast at src/CbcModel.cpp line ~6255 with static_cast. This is due to the way NULL is defined on BSD systems. See this commit for more information.
Then:
$ ./configure -C --prefix=/home/myuser/coin --exec-prefix=/home/myuser/coin ;
make && make install
clean- In your installation virtual environment,
pip install pybind11. - Determine the path to pybind11's cmake files (this can be done easily by starting python with the verbose flag and importing pybind11).
- Add the following line to or-tools/CMakeLists.txt to point to pybind11's CMake files:
set(pybind11_DIR /home/myuser/venv/lib/python3.11/site-packages/pybind11/share/cmake/pybind11)
find_package(pybind11 REQUIRED)
- Locate
pybind11_protobufproject here. - Search and search and search for installation instructions or a guide on pointing the or-tools CMake configuration to a cloned copy of
pybind11_protobuf - Configure LD_LIBRARY_PATH to include the installed COIN-OR libraries as well as any BLAS on your system (I use libopenblas):
export LD_LIBRARY_PATH=/home/myuser/coin/lib:/home/myuser/libopenblas/lib
- Repeatedly try turning flags on and off while building or-tools:
cmake -S. -Bbuild \
-DBUILD_PYTHON=ON \
-DUSE_SCIP=OFF \
-DBUILD_DEPS=OFF
What did you expect to see
A successful build producing a python package suitable for use on platforms for which no "wheel" is prebuilt on pypi.org.
What did you see instead?
CMake Error at cmake/deps.cmake:169 (find_package):
By not providing "Findpybind11_protobuf.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"pybind11_protobuf", but CMake did not find one.
Could not find a package configuration file provided by "pybind11_protobuf"
with any of the following names:
pybind11_protobufConfig.cmake
pybind11_protobuf-config.cmake
Add the installation prefix of "pybind11_protobuf" to CMAKE_PREFIX_PATH or
set "pybind11_protobuf_DIR" to a directory containing one of the above
files. If "pybind11_protobuf" provides a separate development package or
SDK, be sure it has been installed.
Call Stack (most recent call first):
CMakeLists.txt:435 (include)
Anything else we should know about your project / environment
For operating systems other than macOS, GNU/Linux, and some Windows flavors, there are no prebuilt wheels for the python or-tools library. This means pip install or-tools fails to find a candidate:
$ pip install or-tools
ERROR: Could not find a version that satisfies the requirement or-tools (from versions: none)
ERROR: No matching distribution found for or-toolsAs such, one must resort to building the library from source. Luckily several dependencies are prebuilt for my platform (see the pkg_add step above) and the COIN-OR projects are easier to build than their documentation portrays. My current roadblock is this pybind11_protobuf piece. It is admittedly outside my area of expertise, so without documentation detailing installation or integration procedures, I am left with a guess-test-and-revise strategy.