Repository navigation
Add .deb installation and pimpl / name-keyed Configuration - #2
Merged
Merged
Conversation
Mirror the best practices from marinhoLab/solver-qpoases: - pimpl + std::variant Configuration (keyed by option name): The public header include/marinholab/solvers/osqp.h is now OSQP-free. Solver uses the pimpl idiom, and Configuration is keyed by name with typed OptionValue = std::variant<bool, long long, double, std::string> (exposing set/get/has/keys/defaults/reset). Defaults are taken directly from OSQP's osqp_set_default_settings(), with verbose defaulting to off so the solver is quiet. The pybind11 module binds the name-keyed Configuration with native Python values; the OSQP enums move to a pure-Python _options.py (LinsysSolverType, PreconditionerType, Status). - Debian (.deb) packaging for the C++ part: Added debian/ (libmarinholab-solver-osqp), cmake/GetVersion.cmake (rolling YY.MM.NN version), tools/version.sh + tools/bump-changelog.sh, and docker/build-deb.sh + docker/deb.Dockerfile. The vendored OSQP is built static and bundled; the .deb depends only on the C++ runtime. Supporting changes: - CMakeLists.txt now produces a shared-by-default marinholab_osqp library (alias marinholab::solvers::osqp) with a BUILD_PYTHON option and a CMake package config for find_package consumers. - Vendored OSQP's linear-solver qdldl as a git submodule and pointed OSQP's FetchContent at it, so configure time needs no network access. - setup.py passes -DBUILD_PYTHON=ON; docker/compose.yml now runs the pytest suite before the example. - Added tests/test_solver.py (solver reuse + Configuration conversion) and updated examples/README/AGENTS.md to the new name-keyed API. Co-authored-by: openhands <openhands@all-hands.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mirrors the best practices from
marinhoLab/solver-qpoases.This PR was created by an AI agent (OpenHands) on behalf of the user.
1. pimpl +
std::variantname-keyedConfigurationThe public header
include/marinholab/solvers/osqp.his now OSQP-free:Solveruses the pimpl idiom (struct Impl; std::unique_ptr<Impl> impl_;).Configurationis keyed by option name with a typedOptionValue = std::variant<bool, long long, double, std::string>, exposingset(key, value)/set(key, const char*)/get/has/keys/reset/reset_all/defaults. Values are validated and converted tothe option's kind at
set()time (so a wrong type/key raisesstd::invalid_argumentimmediately, not at solve time).osqp_set_default_settings()(
detail::default_values), with one documented exception:verbosedefaults to
false(quiet) instead of OSQP's owntrue.Configurationwith native Pythonvalues (bool/int/float/str + enum-by-name). The OSQP enums move out of the
compiled extension into a pure-Python
_options.py(
LinsysSolverType,PreconditionerType,Status), so the C++ header hasno OSQP types.
API change: the old attribute style (
config.eps_abs = 1e-9) becomes thename-keyed style (
config.set("eps_abs", 1e-9)), matchingsolver-qpoases.Examples,
evaluation/, andREADME.mdare updated accordingly.2. Debian (.deb) packaging for the C++ part
debian/(packagelibmarinholab-solver-osqp):control,copyright(LGPL-2.1+ wrapper + Apache-2.0 OSQP),
changelog,rules(CMake,-O3,-fno-lto),source/format.cmake/GetVersion.cmakecomputes a rollingYY.MM.NNversion (fromtools/version.sh, with a fallback).tools/version.sh+tools/bump-changelog.sh.docker/build-deb.sh+docker/deb.Dockerfilebuild the.debin anUbuntu noble container (optionally
--testto install it and build/run afind_packageconsumer).The vendored OSQP is built static and bundled, so the
.debdepends onlyon the C++ runtime (
libc6,libgcc-s1,libstdc++6). Verified end-to-end:dpkg-buildpackage→dpkg -i→find_package(marinholab_solver_osqp)consumer builds and solves.
Supporting changes
CMakeLists.txt: shared-by-defaultmarinholab_osqplibrary (aliasmarinholab::solvers::osqp), aBUILD_PYTHONoption, version + installrules, and a CMake package config (
cmake/marinholab_solver_osqp-config.cmake.in)for
find_packageconsumers.qdldlas a git submodule and pointed OSQP'sFetchContentat it, so configure time needs no network access(reproducible, offline-friendly).
setup.pypasses-DBUILD_PYTHON=ON;docker/compose.ymlruns the pytestsuite before the example.
tests/test_solver.py(solver reuse across shape changes +Configurationconversion/defaults); updatedREADME.mdandAGENTS.md.Verification (local)
cmake -DBUILD_EXAMPLES=ONbuilds; example printsx = [0.2, 1.0].pip install .+osqp_examplerun; 46/46 pytest pass.pyright→ 0 errors / 0 warnings..deb: built withdocker/build-deb.sh --test; consumerx = [0.2, 1.0].