From f25727a6fabf6d3ec3551de40296931b9606e5d2 Mon Sep 17 00:00:00 2001 From: Zedong Peng Date: Mon, 9 Mar 2026 13:36:54 -0400 Subject: [PATCH 1/3] fix reduced costs typo in python binding --- python_bindings/_core_bindings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python_bindings/_core_bindings.cpp b/python_bindings/_core_bindings.cpp index 0329d96..f46924f 100644 --- a/python_bindings/_core_bindings.cpp +++ b/python_bindings/_core_bindings.cpp @@ -543,7 +543,7 @@ static py::dict solve_once(py::object A, auto xb = x.request(), yb = y.request(), rcb = rc.request(); std::memcpy(xb.ptr, res->primal_solution, sizeof(double) * n_out); std::memcpy(yb.ptr, res->dual_solution, sizeof(double) * m_out); - std::memcpy(rcb.ptr, res->reduced_costs, sizeof(double) * n_out); + std::memcpy(rcb.ptr, res->reduced_cost, sizeof(double) * n_out); } // build info dict py::dict info; From 03572ad30ff69f5fa0ea09bfa8b50f27bdb947e2 Mon Sep 17 00:00:00 2001 From: ZedongPeng Date: Mon, 9 Mar 2026 14:07:22 -0400 Subject: [PATCH 2/3] fix windows DLL failure --- pyproject.toml | 2 +- python_bindings/CMakeLists.txt | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9275d41..9e402ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ dependencies = ["numpy>=1.21", "scipy>=1.8"] [tool.scikit-build] build-dir = "build/{wheel_tag}" -cmake.version = ">=3.20" +cmake.version = ">=3.21" cmake.build-type = "Release" wheel.packages = ["python/cupdlpx"] sdist.include = ["tests/**", "pyproject.toml", "README.md", "LICENSE"] diff --git a/python_bindings/CMakeLists.txt b/python_bindings/CMakeLists.txt index 691ed12..bdf56bf 100644 --- a/python_bindings/CMakeLists.txt +++ b/python_bindings/CMakeLists.txt @@ -1,6 +1,6 @@ # python_bindings/CMakeLists.txt -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.21) # sources set(PYBIND_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/_core_bindings.cpp) @@ -13,11 +13,13 @@ target_link_libraries(_cupdlpx_core PRIVATE ) # set rpath so that the module can find the shared libraries at runtime -set_target_properties(_cupdlpx_core PROPERTIES - BUILD_WITH_INSTALL_RPATH TRUE - INSTALL_RPATH "$ORIGIN/../lib" - BUILD_RPATH "$ORIGIN/../lib" -) +if(NOT WIN32) + set_target_properties(_cupdlpx_core PROPERTIES + BUILD_WITH_INSTALL_RPATH TRUE + INSTALL_RPATH "$ORIGIN/../lib" + BUILD_RPATH "$ORIGIN/../lib" + ) +endif() # better error messages from pybind11 target_compile_definitions(_cupdlpx_core PRIVATE PYBIND11_DETAILED_ERROR_MESSAGES=1) @@ -34,3 +36,12 @@ install(TARGETS _cupdlpx_core RUNTIME DESTINATION cupdlpx ARCHIVE DESTINATION cupdlpx ) + +if(WIN32) + # Install runtime DLL dependencies next to the extension module so Python can + # resolve them without additional os.add_dll_directory(...) calls. + install(FILES $ + DESTINATION cupdlpx + OPTIONAL + ) +endif() From f000257d1cf1073a8453c73ab0369d32d88deac3 Mon Sep 17 00:00:00 2001 From: ZedongPeng Date: Mon, 9 Mar 2026 21:42:30 -0400 Subject: [PATCH 3/3] update --- python/cupdlpx/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/python/cupdlpx/__init__.py b/python/cupdlpx/__init__.py index 6d280e4..20bb776 100644 --- a/python/cupdlpx/__init__.py +++ b/python/cupdlpx/__init__.py @@ -12,6 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os +import platform + +# Windows only: register CUDA bin for dependent DLL loading. +if platform.system() == "Windows": + cuda_path = os.environ.get("CUDA_PATH") + if cuda_path: + bin_path = os.path.join(cuda_path, "bin") + if os.path.isdir(bin_path): + os.add_dll_directory(bin_path) + from .model import Model from . import PDLP @@ -23,4 +34,4 @@ try: __version__ = version("cupdlpx") except PackageNotFoundError: - __version__ = "0.0.0" \ No newline at end of file + __version__ = "0.0.0"