Skip to content

Commit 03572ad

Browse files
committed
fix windows DLL failure
1 parent f25727a commit 03572ad

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dependencies = ["numpy>=1.21", "scipy>=1.8"]
1919

2020
[tool.scikit-build]
2121
build-dir = "build/{wheel_tag}"
22-
cmake.version = ">=3.20"
22+
cmake.version = ">=3.21"
2323
cmake.build-type = "Release"
2424
wheel.packages = ["python/cupdlpx"]
2525
sdist.include = ["tests/**", "pyproject.toml", "README.md", "LICENSE"]

python_bindings/CMakeLists.txt

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# python_bindings/CMakeLists.txt
22

3-
cmake_minimum_required(VERSION 3.20)
3+
cmake_minimum_required(VERSION 3.21)
44

55
# sources
66
set(PYBIND_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/_core_bindings.cpp)
@@ -13,11 +13,13 @@ target_link_libraries(_cupdlpx_core PRIVATE
1313
)
1414

1515
# set rpath so that the module can find the shared libraries at runtime
16-
set_target_properties(_cupdlpx_core PROPERTIES
17-
BUILD_WITH_INSTALL_RPATH TRUE
18-
INSTALL_RPATH "$ORIGIN/../lib"
19-
BUILD_RPATH "$ORIGIN/../lib"
20-
)
16+
if(NOT WIN32)
17+
set_target_properties(_cupdlpx_core PROPERTIES
18+
BUILD_WITH_INSTALL_RPATH TRUE
19+
INSTALL_RPATH "$ORIGIN/../lib"
20+
BUILD_RPATH "$ORIGIN/../lib"
21+
)
22+
endif()
2123

2224
# better error messages from pybind11
2325
target_compile_definitions(_cupdlpx_core PRIVATE PYBIND11_DETAILED_ERROR_MESSAGES=1)
@@ -34,3 +36,12 @@ install(TARGETS _cupdlpx_core
3436
RUNTIME DESTINATION cupdlpx
3537
ARCHIVE DESTINATION cupdlpx
3638
)
39+
40+
if(WIN32)
41+
# Install runtime DLL dependencies next to the extension module so Python can
42+
# resolve them without additional os.add_dll_directory(...) calls.
43+
install(FILES $<TARGET_RUNTIME_DLLS:_cupdlpx_core>
44+
DESTINATION cupdlpx
45+
OPTIONAL
46+
)
47+
endif()

0 commit comments

Comments
 (0)