Skip to content

Commit

Permalink
python whl on Windows now installs the dlls to the proper location
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianReimold committed Mar 18, 2021
1 parent 8e77bce commit c6eb841
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 13 deletions.
2 changes: 2 additions & 0 deletions lang/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ if(Python_Interpreter_FOUND)
WORKING_DIRECTORY ${PYTHON_BINARY_DIR}
COMMENT "Creating python wheel"
)

set_property(TARGET ${create_python_wheel} PROPERTY FOLDER lang/python)
else()
message(FATAL_ERROR "Could not find python interpreter! This is needed to install the eCAL python binding!")
endif()
Expand Down
27 changes: 22 additions & 5 deletions lang/python/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,38 @@
#
# ========================= eCAL LICENSE =================================

if (WIN32)
add_custom_target(copy_ecal_core_dll ALL
COMMAND cmake -E copy_if_different "$<TARGET_FILE:eCAL::core>" "${PYTHON_BINARY_MODULE_DIR}"
COMMENT "Copy eCAL Core DLL to python directory"
DEPENDS eCAL::core
)
set_property(TARGET copy_ecal_core_dll PROPERTY FOLDER lang/python/core)
endif()

# ==========================================

project(_ecal_core_py)

find_package(Python COMPONENTS Development Interpreter)
find_package(Protobuf REQUIRED)

set(ecal_lang_py_src
src/ecal_wrap.cxx
)

ecal_add_python_module(${PROJECT_NAME} SOURCES ${ecal_lang_py_src} PYTHON_CODE ${CMAKE_CURRENT_SOURCE_DIR}/ecal)

target_link_libraries(${PROJECT_NAME} PRIVATE Python::Python)
target_link_libraries(${PROJECT_NAME} PRIVATE eCAL::core)
target_link_libraries(${PROJECT_NAME} PRIVATE eCAL::pb)
target_link_libraries(${PROJECT_NAME}
PRIVATE
Python::Python
eCAL::core
eCAL::pb
)

find_package(Protobuf REQUIRED)
if (WIN32)
add_dependencies(${PROJECT_NAME} copy_ecal_core_dll)
endif()

set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER lang/python/core)

Expand All @@ -41,4 +58,4 @@ if(ECAL_INCLUDE_PY_SAMPLES)
set_property(TARGET ecal_core_py PROPERTY FOLDER lang/python/core)

endif()
endif()
endif()
26 changes: 24 additions & 2 deletions lang/python/ecalhdf5/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
#
# ========================= eCAL LICENSE =================================

if (WIN32)
if (TARGET hdf5::hdf5-shared)
add_custom_target(copy_hdf5_dll ALL
COMMAND cmake -E copy_if_different "$<TARGET_FILE:hdf5::hdf5-shared>" "${PYTHON_BINARY_MODULE_DIR}"
COMMENT "Copy hdf5 DLL to python directory"
DEPENDS hdf5::hdf5-shared
)
set_property(TARGET copy_hdf5_dll PROPERTY FOLDER lang/python/hdf5)
endif()
endif()

# ==========================================

project(_ecal_hdf5_py)

find_package(Python COMPONENTS Development)
Expand All @@ -26,8 +39,17 @@ set(ecal_lang_py_src

ecal_add_python_module(${PROJECT_NAME} SOURCES ${ecal_lang_py_src} PYTHON_CODE ${CMAKE_CURRENT_SOURCE_DIR}/ecal)

target_link_libraries(${PROJECT_NAME} PRIVATE Python::Python)
target_link_libraries(${PROJECT_NAME} PRIVATE eCAL::hdf5)
target_link_libraries(${PROJECT_NAME}
PRIVATE
Python::Python
eCAL::hdf5
)

if (WIN32)
if (TARGET hdf5::hdf5-shared)
add_dependencies(${PROJECT_NAME} copy_hdf5_dll)
endif()
endif()

if(MSVC)
set_property(TARGET ${PROJECT_NAME} PROPERTY LINK_FLAGS "/ignore:4098,4099")
Expand Down
8 changes: 2 additions & 6 deletions lang/python/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ class BinaryDistribution(Distribution):
# this is the input file for cmake. for further details have a look at the
# CMakeLists.txt in this directory.

data_files_platform = []
if platform.system() == 'Windows':
data_files_platform = [('ecal',["../bin/Release/ecal_core.dll", "../bin/Release/hdf5.dll"])]

setuptools.setup (
name = 'ecal',
version = '@eCAL_VERSION_STRING@',
Expand All @@ -42,8 +38,8 @@ setuptools.setup (
author = 'Rex Schilasky',
author_email = '[email protected]',
packages = setuptools.find_packages(),
data_files = data_files_platform,
package_data = {'ecal': ['*.pyd', '*.so']},
data_files = [],
package_data = {'ecal': ['*.pyd', '*.so', '*.dll']},
install_requires = [
'protobuf@Protobuf_required_versions@'
],
Expand Down

0 comments on commit c6eb841

Please sign in to comment.