diff --git a/.github/workflows/build_default.yml b/.github/workflows/build_default.yml index a66c4a04..da05f546 100644 --- a/.github/workflows/build_default.yml +++ b/.github/workflows/build_default.yml @@ -46,8 +46,8 @@ jobs: cibw_archs: "auto" - os: windows-2022 cibw_archs: "auto64" - # Include macos-13 to get Intel x86_64 macs and maos-latest to get the Aaarch64 macs - - os: macos-13 + # Include macos-15-intel to get Intel x86_64 macs and macos-latest to get the Aaarch64 macs + - os: macos-15-intel cibw_archs: "x86_64" - os: macos-latest cibw_archs: "arm64" diff --git a/.github/workflows/build_mkl.yml b/.github/workflows/build_mkl.yml index 67f5c677..1457633a 100644 --- a/.github/workflows/build_mkl.yml +++ b/.github/workflows/build_mkl.yml @@ -17,9 +17,9 @@ jobs: strategy: fail-fast: false matrix: - # macos-latest now uses arm64 runners, but MKL is x86_64 only, so restrict to the macos-13 runners + # macos-latest now uses arm64 runners, but MKL is x86_64 only, so restrict to the macos-15-intel runners # to get x86_64 architecture. - os: [ubuntu-latest, macos-13] + os: [ubuntu-latest, macos-15-intel] steps: - uses: actions/checkout@master diff --git a/CMakeLists.txt b/CMakeLists.txt index 33349318..231fbe5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required(VERSION 3.15...3.26) project(ext) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(PYTHON "ON") set(OSQP_BUILD_UNITTESTS "OFF") set(OSQP_USE_LONG "OFF") diff --git a/cibuildwheel.toml b/cibuildwheel.toml index 4b8cb2f8..a9082b9d 100644 --- a/cibuildwheel.toml +++ b/cibuildwheel.toml @@ -6,15 +6,17 @@ before-build = "rm -rf {package}/osqp_sources/build" # Install CPU-only version of torch beforehand since that allows cibuildwheel # to satisfy the "test" dependency group install, but much faster. The runtime # cost of torch-based osqp tests are considered negligible so torch-cpu is ok. -before-test = "pip install torch --index-url https://download.pytorch.org/whl/cpu" +before-test = 'pip install scipy --prefer-binary && pip install torch --index-url https://download.pytorch.org/whl/cpu' test-groups = ["test"] test-command = "python -m pytest -s {project}/src/osqp/tests" -# 09/10/25 - Skip testing on cp313-manylinux_aarch64 because torch/numpy deps are unsatisfiable -test-skip = "cp313-manylinux_aarch64" -[tool.cibuildwheel.macos] -# 02/13/25 - Skip testing on cp313-macosx_x86_64 because torch/numpy deps are unsatisfiable -test-skip = "cp313-macosx_x86_64" +[[tool.cibuildwheel.overrides]] +# Platforms on which installing pytorch is problematic, so we skip testing +# the `osqp.nn` module +select = "*manylinux_aarch64 cp313-macosx_x86_64" +before-test = 'pip install scipy --prefer-binary' +test-groups = ["test-no-nn"] +test-command = "python -m pytest -s {project}/src/osqp/tests --continue-on-collection-errors --ignore={project}/src/osqp/tests/nn_test.py" [tool.cibuildwheel.pyodide] build = "cp312-pyodide_wasm32" diff --git a/src/bindings.cpp.in b/src/bindings.cpp.in index 817ffe6d..6666690e 100644 --- a/src/bindings.cpp.in +++ b/src/bindings.cpp.in @@ -1,4 +1,5 @@ #include +#include #include #include @@ -132,6 +133,7 @@ class PyOSQPSolver { const CSC& _A; py::array_t _u; OSQPSolver *_solver; + std::unique_ptr _solution_cache; }; PyOSQPSolver::PyOSQPSolver( @@ -143,8 +145,7 @@ PyOSQPSolver::PyOSQPSolver( OSQPInt m, OSQPInt n, const OSQPSettings *settings -): m(m), n(n), _P(P), _A(A) { - this->_solver = new OSQPSolver(); +): m(m), n(n), _P(P), _A(A), _solver(nullptr) { this->_q = q; this->_l = l; this->_u = u; @@ -164,8 +165,10 @@ OSQPSettings* PyOSQPSolver::get_settings() { } PyOSQPSolution& PyOSQPSolver::get_solution() { - PyOSQPSolution* solution = new PyOSQPSolution(*this->_solver->solution, this->m, this->n); - return *solution; + if (!_solution_cache) { + _solution_cache = std::make_unique(*this->_solver->solution, this->m, this->n); + } + return *_solution_cache; } OSQPInfo* PyOSQPSolver::get_info() {