diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 35fdd97d8f..a52d3368ce 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -97,10 +97,6 @@ jobs: run: cmake --build . --config Release working-directory: ${{ runner.workspace }}/_build - - name: Build Python Wheel - run: cmake --build . --target create_python_wheel --config Release - working-directory: ${{ runner.workspace }}/_build - # - name: Build Documentation C # run: cmake --build . --target documentation_c # working-directory: ${{ runner.workspace }}/_build @@ -123,9 +119,3 @@ jobs: with: name: macos-dmg path: ${{ runner.workspace }}/_build/_deploy/*.dmg - - - name: Upload Python Wheel - uses: actions/upload-artifact@v3 - with: - name: macos-python-wheel - path: ${{ runner.workspace }}/_build/_deploy/*.whl diff --git a/.github/workflows/build-ubuntu-20.yml b/.github/workflows/build-ubuntu-20.yml index 2a3431e952..845ed6379e 100644 --- a/.github/workflows/build-ubuntu-20.yml +++ b/.github/workflows/build-ubuntu-20.yml @@ -103,39 +103,6 @@ jobs: run: cmake --build . --config Release -- -k 0 working-directory: ${{ runner.workspace }}/_build - # Create Python Wheels - # The strang-looking double-cmake is an ugly workaround to force CMake to - # re-find Python, after we have changed the venv from the outside. The - # alternative would be to clean everything, which would cause an unnecessary - # rebuild of eCAL for each python Version. - - name: Build Python 3.9 Wheel - run: | - sudo apt-get -y install python3.9-dev python3.9-venv - mkdir ".venv_39" - python3.9 -m venv ".venv_39" - source ".venv_39/bin/activate" - pip install --upgrade pip - pip install wheel setuptools - cmake $GITHUB_WORKSPACE -DPython_FIND_VIRTUALENV=FIRST - cmake $GITHUB_WORKSPACE -DPython_FIND_VIRTUALENV=ONLY - cmake --build . --target create_python_wheel --config Release - shell: bash - working-directory: ${{ runner.workspace }}/_build - - - name: Build Python 3.8 Wheel - run: | - sudo apt-get -y install python3.8-dev python3.8-venv - mkdir ".venv_38" - python3.8 -m venv ".venv_38" - source ".venv_38/bin/activate" - pip install --upgrade pip - pip install wheel setuptools - cmake $GITHUB_WORKSPACE -DPython_FIND_VIRTUALENV=FIRST - cmake $GITHUB_WORKSPACE -DPython_FIND_VIRTUALENV=ONLY - cmake --build . --target create_python_wheel --config Release - shell: bash - working-directory: ${{ runner.workspace }}/_build - - name: Run Tests run: ctest -V working-directory: ${{ runner.workspace }}/_build @@ -150,12 +117,6 @@ jobs: name: ubuntu-debian path: ${{ runner.workspace }}/_build/_deploy/*.deb - - name: Upload Python Wheel - uses: actions/upload-artifact@v3 - with: - name: ubuntu-python-wheel - path: ${{ runner.workspace }}/_build/_deploy/*.whl - #--------------------------------------------------------------------------- # GNU tar - Excluding Some Files diff --git a/.github/workflows/build-ubuntu-22.yml b/.github/workflows/build-ubuntu-22.yml index 97eb142087..63a7bce157 100644 --- a/.github/workflows/build-ubuntu-22.yml +++ b/.github/workflows/build-ubuntu-22.yml @@ -103,39 +103,6 @@ jobs: run: cmake --build . --config Release -- -k 0 working-directory: ${{ runner.workspace }}/_build - # Create Python Wheels - # The strang-looking double-cmake is an ugly workaround to force CMake to - # re-find Python, after we have changed the venv from the outside. The - # alternative would be to clean everything, which would cause an unnecessary - # rebuild of eCAL for each python Version. - - name: Build Python 3.11 Wheel - run: | - sudo apt-get -y install python3.11-dev python3.11-venv - mkdir ".venv_311" - python3.11 -m venv ".venv_311" - source ".venv_311/bin/activate" - pip install --upgrade pip - pip install wheel setuptools - cmake $GITHUB_WORKSPACE -DPython_FIND_VIRTUALENV=FIRST - cmake $GITHUB_WORKSPACE -DPython_FIND_VIRTUALENV=ONLY - cmake --build . --target create_python_wheel --config Release - shell: bash - working-directory: ${{ runner.workspace }}/_build - - - name: Build Python 3.10 Wheel - run: | - sudo apt-get -y install python3.10-dev python3.10-venv - mkdir ".venv_310" - python3.10 -m venv ".venv_310" - source ".venv_310/bin/activate" - pip install --upgrade pip - pip install wheel setuptools - cmake $GITHUB_WORKSPACE -DPython_FIND_VIRTUALENV=FIRST - cmake $GITHUB_WORKSPACE -DPython_FIND_VIRTUALENV=ONLY - cmake --build . --target create_python_wheel --config Release - shell: bash - working-directory: ${{ runner.workspace }}/_build - - name: Run Tests run: ctest -V working-directory: ${{ runner.workspace }}/_build @@ -149,9 +116,3 @@ jobs: with: name: ubuntu-debian path: ${{ runner.workspace }}/_build/_deploy/*.deb - - - name: Upload Python Wheel - uses: actions/upload-artifact@v3 - with: - name: ubuntu-python-wheel - path: ${{ runner.workspace }}/_build/_deploy/*.whl diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index a438226bc2..0ac2b693af 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -139,7 +139,7 @@ jobs: -DBUILD_APPS=ON ^ -DBUILD_SAMPLES=ON ^ -DBUILD_TIME=ON ^ - -DBUILD_PY_BINDING=ON ^ + -DBUILD_PY_BINDING=OFF ^ -DBUILD_CSHARP_BINDING=ON ^ -DBUILD_ECAL_TESTS=ON ^ -DECAL_INCLUDE_PY_SAMPLES=OFF ^ @@ -175,83 +175,6 @@ jobs: run: cmake --build . --config Release working-directory: ${{ runner.workspace }}/_build/complete - # Create Python. - # The strang-looking double-cmake is an ugly workaround to force CMake to - # re-find Python, after we have changed the venv from the outside. The - # alternative would be to clean everything, which would cause an unnecessary - # rebuild of eCAL and HDF5 for each python Version. - - name: Build Python 3.12 Wheel - run: | - mkdir ".venv_312" - py -3.12 -m venv ".venv_312" - CALL ".venv_312\Scripts\activate.bat" - pip install wheel setuptools - cmake %GITHUB_WORKSPACE% -G "Visual Studio 16 2019" -A x64 -T v142 -DPython_FIND_VIRTUALENV=FIRST - cmake %GITHUB_WORKSPACE% -G "Visual Studio 16 2019" -A x64 -T v142 -DPython_FIND_VIRTUALENV=ONLY - cmake --build . --target create_python_wheel --config Release - shell: cmd - working-directory: ${{ runner.workspace }}/_build/complete - - - name: Build Python 3.11 Wheel - run: | - mkdir ".venv_311" - py -3.11 -m venv ".venv_311" - CALL ".venv_311\Scripts\activate.bat" - pip install wheel - cmake %GITHUB_WORKSPACE% -G "Visual Studio 16 2019" -A x64 -T v142 -DPython_FIND_VIRTUALENV=FIRST - cmake %GITHUB_WORKSPACE% -G "Visual Studio 16 2019" -A x64 -T v142 -DPython_FIND_VIRTUALENV=ONLY - cmake --build . --target create_python_wheel --config Release - shell: cmd - working-directory: ${{ runner.workspace }}/_build/complete - - - name: Build Python 3.10 Wheel - run: | - mkdir ".venv_310" - py -3.10 -m venv ".venv_310" - CALL ".venv_310\Scripts\activate.bat" - pip install wheel - cmake %GITHUB_WORKSPACE% -G "Visual Studio 16 2019" -A x64 -T v142 -DPython_FIND_VIRTUALENV=FIRST - cmake %GITHUB_WORKSPACE% -G "Visual Studio 16 2019" -A x64 -T v142 -DPython_FIND_VIRTUALENV=ONLY - cmake --build . --target create_python_wheel --config Release - shell: cmd - working-directory: ${{ runner.workspace }}/_build/complete - - - name: Build Python 3.9 Wheel - run: | - mkdir ".venv_39" - py -3.9 -m venv ".venv_39" - CALL ".venv_39\Scripts\activate.bat" - pip install wheel - cmake %GITHUB_WORKSPACE% -G "Visual Studio 16 2019" -A x64 -T v142 -DPython_FIND_VIRTUALENV=FIRST - cmake %GITHUB_WORKSPACE% -G "Visual Studio 16 2019" -A x64 -T v142 -DPython_FIND_VIRTUALENV=ONLY - cmake --build . --target create_python_wheel --config Release - shell: cmd - working-directory: ${{ runner.workspace }}/_build/complete - - - name: Build Python 3.8 Wheel - run: | - mkdir ".venv_38" - py -3.8 -m venv ".venv_38" - CALL ".venv_38\Scripts\activate.bat" - pip install wheel - cmake %GITHUB_WORKSPACE% -G "Visual Studio 16 2019" -A x64 -T v142 -DPython_FIND_VIRTUALENV=FIRST - cmake %GITHUB_WORKSPACE% -G "Visual Studio 16 2019" -A x64 -T v142 -DPython_FIND_VIRTUALENV=ONLY - cmake --build . --target create_python_wheel --config Release - shell: cmd - working-directory: ${{ runner.workspace }}/_build/complete - - - name: Build Python 3.7 Wheel - run: | - mkdir ".venv_37" - py -3.7 -m venv ".venv_37" - CALL ".venv_37\Scripts\activate.bat" - pip install wheel - cmake %GITHUB_WORKSPACE% -G "Visual Studio 16 2019" -A x64 -T v142 -DPython_FIND_VIRTUALENV=FIRST - cmake %GITHUB_WORKSPACE% -G "Visual Studio 16 2019" -A x64 -T v142 -DPython_FIND_VIRTUALENV=ONLY - cmake --build . --target create_python_wheel --config Release - shell: cmd - working-directory: ${{ runner.workspace }}/_build/complete - # - name: Build Documentation C # run: cmake --build . --target documentation_c # working-directory: ${{ runner.workspace }}/_build @@ -306,12 +229,6 @@ jobs: name: windows-setup path: ${{ runner.workspace }}/_build/complete/_deploy/*.exe - - name: Upload Python Wheels - uses: actions/upload-artifact@v3 - with: - name: windows-python-wheels - path: ${{ runner.workspace }}/_build/complete/_deploy/*.whl - # -------------------------------------------------------------------------------------------------- - name: Sign the installer on Eclipse CI diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml new file mode 100644 index 0000000000..9ce5c3af59 --- /dev/null +++ b/.github/workflows/build_wheels.yml @@ -0,0 +1,36 @@ +name: Build + +on: + push: + pull_request: + branches: + - master + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-20.04, windows-2019] + + steps: + - uses: actions/checkout@v3 + with: + submodules: 'true' + fetch-depth: 0 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.15.0 + env: + MACOSX_DEPLOYMENT_TARGET: "10.14" + CIBW_BUILD: "cp39-*" + # ... + # with: + # package-dir: . + # output-dir: wheelhouse + # config-file: "{package}/pyproject.toml" + + - uses: actions/upload-artifact@v3 + with: + path: ./wheelhouse/*.whl diff --git a/CMakeLists.txt b/CMakeLists.txt index d240a156b7..60e0cc1900 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,6 +134,8 @@ set(ECAL_BUILD_VERSION "0.0.0" CACHE STRING "Inject a build version if not build set(ECAL_CSHARP_BUILD_SAMPLES ${BUILD_SAMPLES}) +set(PY_BUILD_CMAKE_MODULE_NAME "_install_py/ecal" CACHE STRING "Cache variable for py install dir") + # there is a CMake issue with testing threading availibility via TEST_RUN if(${CMAKE_CROSSCOMPILING}) @@ -237,7 +239,6 @@ set(eCAL_VERSION ${eCAL_VERSION_STRING}) include(helper_functions/ecal_add_functions) include(helper_functions/ecal_helper_functions) include(helper_functions/ecal_install_functions) -include(helper_functions/ecal_python_functions) if(MSVC) set(eCAL_PLATFORM_TOOLSET ${CMAKE_VS_PLATFORM_TOOLSET}) diff --git a/app/app_pb/CMakeLists.txt b/app/app_pb/CMakeLists.txt index edd036188f..baea68b4a1 100644 --- a/app/app_pb/CMakeLists.txt +++ b/app/app_pb/CMakeLists.txt @@ -74,9 +74,9 @@ target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14) ecal_install_library(${PROJECT_NAME}) if(BUILD_PY_BINDING) - protobuf_generate_python_ext(python_sources ${PYTHON_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src ${ProtoFiles}) - target_sources(${PROJECT_NAME} PRIVATE ${python_sources}) - set_source_files_properties(${python_sources} PROPERTIES HEADER_FILE_ONLY TRUE) + #protobuf_generate_python_ext(python_sources ${PYTHON_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src ${ProtoFiles}) + #target_sources(${PROJECT_NAME} PRIVATE ${python_sources}) + #set_source_files_properties(${python_sources} PROPERTIES HEADER_FILE_ONLY TRUE) endif() set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER app/app_pb) diff --git a/cmake/helper_functions/ecal_python_functions.cmake b/cmake/helper_functions/ecal_python_functions.cmake deleted file mode 100644 index b51b5b179f..0000000000 --- a/cmake/helper_functions/ecal_python_functions.cmake +++ /dev/null @@ -1,112 +0,0 @@ -# ========================= eCAL LICENSE ================================= -# -# Copyright (C) 2016 - 2019 Continental Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ========================= eCAL LICENSE ================================= - -set(PYTHON_BINARY_DIR ${CMAKE_BINARY_DIR}/python) -set(PYTHON_BINARY_MODULE_DIR ${CMAKE_BINARY_DIR}/python/ecal) - -#! ecal_add_python_module : this function adds a python module -# -# This function -# -# \arg:TARGET_NAME the first argument -# \param:SOURCES SOURCES specify the fooness of the function -# \param:PYTHON_CODE PYTHON_CODE should always be 42 -# \group:GROUP1 GROUP1 is a list of project to foo -# -function(ecal_add_python_module TARGET_NAME) - - set(multiValueArgs SOURCES) - set(singleValueArgs PYTHON_CODE) - cmake_parse_arguments(ARGUMENTS - "" - "${singleValueArgs}" - "${multiValueArgs}" ${ARGN} ) - - if(NOT ARGUMENTS_SOURCES AND NOT ARGUMENTS_PYTHON_CODE) - message(ERROR "Error in ecal_add_python_module: Please specify SOURCES and / or PYTHON_CODE arguments") - endif() - - - # if Sources are specified, a library is created - if(ARGUMENTS_SOURCES) - Python_add_library(${TARGET_NAME} MODULE ${ARGUMENTS_SOURCES}) - set_target_properties(${TARGET_NAME} - PROPERTIES - PREFIX "" - LIBRARY_OUTPUT_DIRECTORY_DEBUG "${PYTHON_BINARY_MODULE_DIR}" - LIBRARY_OUTPUT_DIRECTORY_RELEASE "${PYTHON_BINARY_MODULE_DIR}" - LIBRARY_OUTPUT_DIRECTORY "${PYTHON_BINARY_MODULE_DIR}" - DEBUG_POSTFIX "_d" - ) - # if no sources are specified, then a custom target needs to be created - else() - add_custom_target(${TARGET_NAME} ALL - COMMENT "Custom python target: ${TARGET_NAME}") - endif() - - if(ARGUMENTS_PYTHON_CODE) - # Copy all files from the source folder to the python binary directory. - get_filename_component(absolute_folder_python_files ${ARGUMENTS_PYTHON_CODE} ABSOLUTE) - file(GLOB_RECURSE relative_python_files - RELATIVE ${absolute_folder_python_files} - LIST_DIRECTORIES false - CONFIGURE_DEPENDS - ${absolute_folder_python_files}/*.py) - - foreach (f ${relative_python_files}) - set(origin_file ${absolute_folder_python_files}/${f}) - set(destination_file ${PYTHON_BINARY_MODULE_DIR}/${f}) - configure_file(${origin_file} ${destination_file} COPYONLY) - endforeach() - endif() -endfunction() - -function(ecal_add_pybind11_module TARGET_NAME) - set(multiValueArgs SOURCES) - set(singleValueArgs PYTHON_CODE) - cmake_parse_arguments(ARGUMENTS - "" - "${singleValueArgs}" - "${multiValueArgs}" ${ARGN} ) - - if(NOT ARGUMENTS_SOURCES AND NOT ARGUMENTS_PYTHON_CODE) - message(ERROR "Error in ecal_add_python_module: Please specify SOURCES and / or PYTHON_CODE arguments") - endif() - - - pybind11_add_module(${TARGET_NAME} ${ARGUMENTS_SOURCES}) - set_target_properties(${TARGET_NAME} - PROPERTIES - PREFIX "" - LIBRARY_OUTPUT_DIRECTORY_DEBUG "${PYTHON_BINARY_MODULE_DIR}" - LIBRARY_OUTPUT_DIRECTORY_RELEASE "${PYTHON_BINARY_MODULE_DIR}" - LIBRARY_OUTPUT_DIRECTORY "${PYTHON_BINARY_MODULE_DIR}" - DEBUG_POSTFIX "_d" - ) - - if(ARGUMENTS_PYTHON_CODE) - add_custom_command( - TARGET ${TARGET_NAME} - PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory ${ARGUMENTS_PYTHON_CODE} ${PYTHON_BINARY_MODULE_DIR} - ) - endif() -endfunction () - -function(ecal_install_python_module) -endfunction() \ No newline at end of file diff --git a/conanfile.py b/conanfile.py index 7056bb0454..ae3195935d 100644 --- a/conanfile.py +++ b/conanfile.py @@ -6,51 +6,68 @@ class eCALConan(ConanFile): name = "ecal" - settings = "os", "compiler", "arch", "build_type" + settings = "os", "compiler", "arch" license = "BSD-3-Clause" - generators = "virtualenv" - build_requires = "cmake/3.21.1" + generators = "virtualenv", "virtualrunenv" + python_requires = {"cmake-presets-generator/0.1.0@ild/stable", "conancontifile/0.0.19@ild/stable"} def build_requirements(self): - self.build_requires("doxygen/1.9.1") + self.build_requires("doxygen/[*]@ild/stable") + self.build_requires("cmake/[*]@ild/stable") + self.build_requires("cmake/[*]@ild/stable") def requirements(self): - self.requires("hdf5/1.10.6") - self.requires("protobuf/3.17.1") - self.requires("libcurl/7.78.0") - self.requires("qt/5.15.2") - self.requires("spdlog/1.9.2") - #self.requires("tclap/1.2.4") - #self.requires("asio/1.19.2") - self.requires("gtest/1.11.0") - self.requires("tinyxml2/8.0.0") - self.requires("openssl/1.1.1l", override=True) - - def configure(self): - if self.settings.os == "Windows": - self.options["qt"].shared = True - self.options["qt"].qtwinextras = True + #self.requires("asio/[*]@ild/stable"") + #self.requires("tclap/[*]@ild/stable"") + self.requires("capnproto/[*]@ild/stable") + self.requires("cmakefunctions/[*]@ild/stable") + self.requires("curl/[*]@ild/stable") + self.requires("fineftp-server/[*]@ild/stable") + self.requires("flatbuffers/[*]@ild/stable") + self.requires("ftxui/[*]@ild/stable") + self.requires("gtest/[*]@ild/stable") + self.requires("hdf5/[*]@ild/stable") + self.requires("openssl/1.1.1i@ild/stable") + self.requires("protobuf/3.23.4@ild/stable") + self.requires("qt/[*]@ild/stable") + self.requires("qwt/[*]@ild/stable") + self.requires("recycle/[*]@ild/stable") + self.requires("simpleini/[*]@ild/stable") + self.requires("spdlog/[*]@ild/stable") + self.requires("tcp-pubsub/[*]@ild/stable") + self.requires("termcolor/[*]@ild/stable") + self.requires("tinyxml2/[*]@ild/stable") + self.requires("udpcap/[*]@ild/stable") + self.requires("yaml-cpp/[*]@ild/stable") def generate(self): - # Don't generate the config files for doxygen. They don't work properlyexit - self.deps_cpp_info["doxygen"].set_property("cmake_find_mode", "none") - cmake = CMakeDeps(self) - cmake.generate() - - tc = CMakeToolchain(self) + CMakePresets = self.python_requires["cmake-presets-generator"].module.CMakePresets + cmake_folder = self.recipe_folder + tc = CMakePresets(self, cmake_folder=".") # customize toolchain "tc" + tc.variables["BUILD_DOCS"] = "ON" + tc.variables["BUILD_ECAL_TESTS"] = "ON" + tc.variables["BUILD_PY_BINDING"] = "ON" + tc.variables["CMAKE_FIND_PACKAGE_PREFER_CONFIG"] = "ON" + tc.variables["HAS_CAPNPROTO"] = "ON" + tc.variables["HAS_FLATBUFFERS"] = "ON" + tc.variables["ECAL_INCLUDE_PY_SAMPLES"] = "ON" + tc.variables["ECAL_THIRDPARTY_BUILD_CMAKE_FUNCTIONS"] = "OFF" tc.variables["ECAL_THIRDPARTY_BUILD_CURL"] = "OFF" - tc.variables["ECAL_THIRDPARTY_BUILD_SPDLOG"] = "OFF" + tc.variables["ECAL_THIRDPARTY_BUILD_FINEFTP"] = "OFF" + tc.variables["ECAL_THIRDPARTY_BUILD_FTXUI"] = "OFF" tc.variables["ECAL_THIRDPARTY_BUILD_GTEST"] = "OFF" - tc.variables["ECAL_THIRDPARTY_BUILD_PROTOBUF"] = "OFF" tc.variables["ECAL_THIRDPARTY_BUILD_HDF5"] = "OFF" + tc.variables["ECAL_THIRDPARTY_BUILD_PROTOBUF"] = "OFF" + tc.variables["ECAL_THIRDPARTY_BUILD_QWT"] = "OFF" + tc.variables["ECAL_THIRDPARTY_BUILD_RECYCLE"] = "OFF" + tc.variables["ECAL_THIRDPARTY_BUILD_RECYCLE"] = "OFF" + tc.variables["ECAL_THIRDPARTY_BUILD_SPDLOG"] = "OFF" + tc.variables["ECAL_THIRDPARTY_BUILD_TCP_PUBSUB"] = "OFF" + tc.variables["ECAL_THIRDPARTY_BUILD_TERMCOLOR"] = "OFF" tc.variables["ECAL_THIRDPARTY_BUILD_TINYXML2"] = "OFF" - tc.variables["BUILD_DOCS"] = "ON" - tc.variables["CMAKE_FIND_PACKAGE_PREFER_CONFIG"] = "ON" - if self.settings.os == "Windows": - tc.variables["Protobuf_PROTOC_EXECUTABLE"] = os.path.join(self.deps_cpp_info["protobuf"].rootpath, "bin", "protoc.exe").replace('\\', '/') - else: - tc.variables["Protobuf_PROTOC_EXECUTABLE"] = os.path.join(self.deps_cpp_info["protobuf"].rootpath, "bin", "protoc") + tc.variables["ECAL_THIRDPARTY_BUILD_UDPCAP"] = "OFF" + tc.variables["ECAL_THIRDPARTY_BUILD_YAML-CPP"] = "OFF" tc.generate() diff --git a/contrib/ecaltime/ecaltime_pb/CMakeLists.txt b/contrib/ecaltime/ecaltime_pb/CMakeLists.txt index 4c4dc0ab16..0fa61abf59 100644 --- a/contrib/ecaltime/ecaltime_pb/CMakeLists.txt +++ b/contrib/ecaltime/ecaltime_pb/CMakeLists.txt @@ -63,9 +63,9 @@ target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14) ecal_install_library(${PROJECT_NAME}) if(BUILD_PY_BINDING) - protobuf_generate_python_ext(python_sources ${PYTHON_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src ${ProtoFiles}) - target_sources(${PROJECT_NAME} PRIVATE ${python_sources}) - set_source_files_properties(${python_sources} PROPERTIES HEADER_FILE_ONLY TRUE) + #protobuf_generate_python_ext(python_sources ${PYTHON_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src ${ProtoFiles}) + #target_sources(${PROJECT_NAME} PRIVATE ${python_sources}) + #set_source_files_properties(${python_sources} PROPERTIES HEADER_FILE_ONLY TRUE) endif() set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER contrib/ecaltime/ecaltime_pb) diff --git a/ecal/core_pb/CMakeLists.txt b/ecal/core_pb/CMakeLists.txt index e8f0704c7d..76438d39bd 100644 --- a/ecal/core_pb/CMakeLists.txt +++ b/ecal/core_pb/CMakeLists.txt @@ -69,9 +69,9 @@ target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14) ecal_install_library(${PROJECT_NAME}) if(BUILD_PY_BINDING) - protobuf_generate_python_ext(python_sources ${PYTHON_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src ${ProtoFiles}) - target_sources(${PROJECT_NAME} PRIVATE ${python_sources}) - set_source_files_properties(${python_sources} PROPERTIES HEADER_FILE_ONLY TRUE) + #protobuf_generate_python_ext(python_sources ${PYTHON_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src ${ProtoFiles}) + #target_sources(${PROJECT_NAME} PRIVATE ${python_sources}) + #set_source_files_properties(${python_sources} PROPERTIES HEADER_FILE_ONLY TRUE) endif() set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER ecal/core_pb) diff --git a/lang/python/CMakeLists.txt b/lang/python/CMakeLists.txt index be9c65a944..93f556fe1f 100644 --- a/lang/python/CMakeLists.txt +++ b/lang/python/CMakeLists.txt @@ -21,48 +21,6 @@ project(_ecal_py) find_package(Python COMPONENTS Development Interpreter) find_package(Protobuf REQUIRED) -set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in") -set(SETUP_PY "${PYTHON_BINARY_DIR}/setup.py") - -# Create a shortened protobuf version string -string(REPLACE "." ";" Protobuf_VERSION_components "${Protobuf_VERSION}") -list(LENGTH Protobuf_VERSION_components Protobuf_VERSION_components_length) - -if ("${Protobuf_VERSION_components_length}" LESS "2") - message(FATAL_ERROR "Unable to determine protobuf version for python binding") -endif() -list(GET Protobuf_VERSION_components 0 Protobuf_VERSION_major) -list(GET Protobuf_VERSION_components 1 Protobuf_VERSION_minor) -MATH(EXPR Protobuf_Version_minor_inc "${Protobuf_VERSION_minor}+1") - -if (Protobuf_VERSION VERSION_LESS "3.19") - set(Protobuf_required_versions ">=${Protobuf_VERSION},<=3.20") -else() - set(Protobuf_required_versions ">=${Protobuf_VERSION}") -endif() - - -configure_file(${SETUP_PY_IN} ${SETUP_PY} @ONLY) - -if(Python_Interpreter_FOUND) - message(STATUS "Python interpreter found: ${Python_EXECUTABLE}") - - # on make install the python module gets installed directly by invocing python interpreter - # TODO: this needs to be tested on windows also - message(STATUS "Installing Python extensions") - #install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} setup.py install --user WORKING_DIRECTORY ${PYTHON_BINARY_DIR})") - add_custom_target(create_python_wheel - ${Python_EXECUTABLE} setup.py bdist_wheel --dist-dir=${BUILD_DEPLOY_DIRECTORY} - DEPENDS _ecal_core_py _ecal_hdf5_py - 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() - add_subdirectory(core) if(HAS_HDF5) add_subdirectory(ecalhdf5) diff --git a/lang/python/core/CMakeLists.txt b/lang/python/core/CMakeLists.txt index 7f63e0b171..404f7d66a2 100644 --- a/lang/python/core/CMakeLists.txt +++ b/lang/python/core/CMakeLists.txt @@ -16,57 +16,34 @@ # # ========================= eCAL LICENSE ================================= -if (WIN32) - add_custom_target(copy_ecal_core_dll ALL - COMMAND cmake -E copy_if_different "$" "${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(Python3 REQUIRED COMPONENTS Development.Module) 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) +Python3_add_library(${PROJECT_NAME} MODULE ${ecal_lang_py_src}) target_link_libraries(${PROJECT_NAME} PRIVATE - Python::Python eCAL::core eCAL::core_pb ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) -if (WIN32) - add_dependencies(${PROJECT_NAME} copy_ecal_core_dll) -endif() - -set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER lang/python/core) - -if(BUILD_STANDALONE_PY_WHEEL AND NOT WIN32) - find_package(patchelf REQUIRED) - add_custom_command(TARGET ${PROJECT_NAME} - POST_BUILD - COMMAND "${CMAKE_COMMAND}" ARGS "-DRUNTIME_FILE=\"$\"" "-DRUNTIME_DEP_FILTER=\"ecal_core|protobuf\"" "-DRUNTIME_DEPLOY_DIR=\"${PYTHON_BINARY_MODULE_DIR}\"" -P "${CMAKE_SOURCE_DIR}/cmake/deploy_runtime_deps.cmake" - COMMAND "${PATCHELF_COMMAND}" ARGS "--remove-rpath" "\"$\"" - COMMAND "${PATCHELF_COMMAND}" ARGS "--force-rpath" "--set-rpath" "\\$$ORIGIN" "\"$\"") -endif() +install(TARGETS ${PROJECT_NAME} + EXCLUDE_FROM_ALL + COMPONENT python_modules + DESTINATION ${PY_BUILD_CMAKE_MODULE_NAME}) -if(ECAL_INCLUDE_PY_SAMPLES) - if(WIN32) +install(PROGRAMS $ + EXCLUDE_FROM_ALL + COMPONENT python_modules + DESTINATION ${PY_BUILD_CMAKE_MODULE_NAME}) - include_external_msproject(ecal_core_py ${CMAKE_CURRENT_SOURCE_DIR}/ecal_core_py.pyproj) - set_property(TARGET ecal_core_py PROPERTY FOLDER lang/python/core) +set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER lang/python/core) - endif() -endif() diff --git a/lang/python/core/ecal_core_py.pyproj b/lang/python/core/ecal_core_py.pyproj deleted file mode 100644 index 010a8ba01d..0000000000 --- a/lang/python/core/ecal_core_py.pyproj +++ /dev/null @@ -1,48 +0,0 @@ - - - - Debug - 2.0 - . - ecal\core\publisher.py - . - . - ecal_core_py - ecal_core_py - {5edaf79b-03b5-317a-b954-9dba8f0b9b9f} - - - true - false - - - true - false - - - - - - - - - - - - - - - - - - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets - - - - - - - - - \ No newline at end of file diff --git a/lang/python/ecal/__init__.py b/lang/python/ecal/__init__.py new file mode 100644 index 0000000000..ea5331b671 --- /dev/null +++ b/lang/python/ecal/__init__.py @@ -0,0 +1,5 @@ +""" +This module contains functions for communicating with eCAL. +""" + +__version__ = "5.12.0" diff --git a/lang/python/ecal/core/__init__.py b/lang/python/ecal/core/__init__.py new file mode 100644 index 0000000000..87b242d5e8 --- /dev/null +++ b/lang/python/ecal/core/__init__.py @@ -0,0 +1,3 @@ +""" +This module contains functions for communicating with eCAL. +""" diff --git a/lang/python/ecal/proto/__init__.py b/lang/python/ecal/proto/__init__.py new file mode 100644 index 0000000000..87b242d5e8 --- /dev/null +++ b/lang/python/ecal/proto/__init__.py @@ -0,0 +1,3 @@ +""" +This module contains functions for communicating with eCAL. +""" diff --git a/lang/python/ecalhdf5/CMakeLists.txt b/lang/python/ecalhdf5/CMakeLists.txt index 7ce0293660..7fab6768af 100644 --- a/lang/python/ecalhdf5/CMakeLists.txt +++ b/lang/python/ecalhdf5/CMakeLists.txt @@ -16,63 +16,48 @@ # # ========================= eCAL LICENSE ================================= -if (WIN32) - if (TARGET hdf5::hdf5-shared) - add_custom_target(copy_hdf5_dll ALL - COMMAND cmake -E copy_if_different "$" "${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() +#if (WIN32) +# if (TARGET hdf5::hdf5-shared) +# add_custom_target(copy_hdf5_dll ALL +# COMMAND cmake -E copy_if_different "$" "${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) +find_package(Python3 REQUIRED COMPONENTS Development.Module) set(ecal_lang_py_src src/ecalhdf5_wrap.cxx ) -ecal_add_python_module(${PROJECT_NAME} SOURCES ${ecal_lang_py_src} PYTHON_CODE ${CMAKE_CURRENT_SOURCE_DIR}/ecal) +Python3_add_library(${PROJECT_NAME} MODULE ${ecal_lang_py_src}) target_link_libraries(${PROJECT_NAME} PRIVATE - Python::Python eCAL::hdf5 ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) -if (WIN32) - if (TARGET hdf5::hdf5-shared) - add_dependencies(${PROJECT_NAME} copy_hdf5_dll) - endif() -endif() +install(TARGETS ${PROJECT_NAME} + EXCLUDE_FROM_ALL + COMPONENT python_modules + DESTINATION ${PY_BUILD_CMAKE_MODULE_NAME}) + +install(PROGRAMS $ + EXCLUDE_FROM_ALL + COMPONENT python_modules + DESTINATION ${PY_BUILD_CMAKE_MODULE_NAME}) if(MSVC) set_property(TARGET ${PROJECT_NAME} PROPERTY LINK_FLAGS "/ignore:4098,4099") endif(MSVC) set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER lang/python/hdf5) - -if(BUILD_STANDALONE_PY_WHEEL AND NOT WIN32) - find_package(patchelf REQUIRED) - add_custom_command(TARGET ${PROJECT_NAME} - POST_BUILD - COMMAND "${CMAKE_COMMAND}" ARGS "-DRUNTIME_FILE=\"$\"" "-DRUNTIME_DEP_FILTER=\"hdf5|sz|aec\"" "-DRUNTIME_DEPLOY_DIR=\"${PYTHON_BINARY_MODULE_DIR}\"" -P "${CMAKE_SOURCE_DIR}/cmake/deploy_runtime_deps.cmake" - COMMAND "${PATCHELF_COMMAND}" ARGS "--remove-rpath" "\"$\"" - COMMAND "${PATCHELF_COMMAND}" ARGS "--force-rpath" "--set-rpath" "\\$$ORIGIN" "\"$\"") -endif() - -if(ECAL_INCLUDE_PY_SAMPLES) - if(WIN32) - - include_external_msproject(ecal_hdf5_py ${CMAKE_CURRENT_SOURCE_DIR}/ecal_hdf5_py.pyproj) - set_property(TARGET ecal_hdf5_py PROPERTY FOLDER lang/python/hdf5) - - endif() -endif() diff --git a/lang/python/ecalhdf5/ecal_hdf5_py.pyproj b/lang/python/ecalhdf5/ecal_hdf5_py.pyproj deleted file mode 100644 index 4230262ad6..0000000000 --- a/lang/python/ecalhdf5/ecal_hdf5_py.pyproj +++ /dev/null @@ -1,43 +0,0 @@ - - - - Debug - 2.0 - . - ecal\measurement\measurement.py - . - . - ecal_hdf5_py - ecal_hdf5_py - {29601a25-64ad-3697-8cf8-39ba154e66ee} - - - true - false - - - true - false - - - - - - - - - - - - - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets - - - - - - - - - \ No newline at end of file diff --git a/lang/python/setup.py.in b/lang/python/setup.py.in deleted file mode 100644 index 6a6028d645..0000000000 --- a/lang/python/setup.py.in +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python - -# ========================= eCAL LICENSE ================================= -# -# Copyright (C) 2016 - 2019 Continental Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ========================= eCAL LICENSE ================================= - -import setuptools -import platform -from setuptools.dist import Distribution - -class BinaryDistribution(Distribution): - """Distribution which always forces a binary package with platform name""" - def has_ext_modules(self): - return True - -# this is the input file for cmake. for further details have a look at the -# CMakeLists.txt in this directory. - -setuptools.setup ( - name = 'ecal5', - version = '@eCAL_VERSION_STRING@', - description = 'This is the eCAL python API', - license = 'Apache 2.0', - author = 'Rex Schilasky', - author_email = 'rex.schilasky@continental-corporation.com', - packages = setuptools.find_packages(), - data_files = [], - package_data = {'ecal': ['*.pyd', '*.so', '*.so.*', '*.dll']}, - install_requires = [ - 'protobuf@Protobuf_required_versions@' - ], - zip_safe=False, - distclass = BinaryDistribution, -) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..99269c2d06 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,64 @@ +[project] # Project metadata +name = "ecal5" +readme = "README.md" +requires-python = ">=3.7" +license = { "file" = "LICENSE.txt" } +authors = [{ "name" = "Kerstin Keller", "email" = "kerstin.keller@continental.com" }] +keywords = ["DDS", "Middlware"] +classifiers = ["Topic :: Scientific/Engineering"] +dependencies = ["protobuf"] +version = "5.13.0-alpha" + +[project.urls] +"Documentation" = "https://eclipse-ecal.github.io/ecal" +"Source" = "https://github.com/eclipse-ecal/ecal" + +[build-system] # How pip and other frontends should build this project +requires = ["scikit-build-core"] +build-backend = "scikit_build_core.build" + +[tool.scikit-build] + +sdist.exclude = ["*"] +sdist.include = ["CMakeLists.txt", "pyproject.toml", "LICENSE.txt", "NOTICE.txt", "README.md", "app/*", "cmake/*", "contrib/*", "cpack/*", "ecal/*", "lib/*", "licenses/*", "lang/python/*", "thirdparty/*"] + +wheel.packages = ["lang/python"] + +[tool.scikit-build.cmake.define] +#WITH_PY_STUBS:BOOL = "On" +HAS_HDF5 = "ON" +HAS_QT5 = "OFF" +HAS_CURL = "OFF" +HAS_FTXUI = "OFF" +BUILD_APPS = "OFF" +BUILD_SAMPLES = "OFF" +BUILD_TIME = "ON" +BUILD_PY_BINDING = "ON" +ECAL_INSTALL_SAMPLE_SOURCES = "OFF" +ECAL_THIRDPARTY_BUILD_CMAKE_FUNCTIONS = "ON" +ECAL_THIRDPARTY_BUILD_SPDLOG = "ON" +ECAL_THIRDPARTY_BUILD_TINYXML2 = "OFF" +ECAL_THIRDPARTY_BUILD_FINEFTP = "OFF" +ECAL_THIRDPARTY_BUILD_TERMCOLOR ="OFF" +ECAL_THIRDPARTY_BUILD_TCP_PUBSUB ="ON" +ECAL_THIRDPARTY_BUILD_RECYCLE = "ON" +ECAL_THIRDPARTY_BUILD_FTXUI = "OFF" +ECAL_THIRDPARTY_BUILD_PROTOBUF = "ON" +ECAL_THIRDPARTY_BUILD_YAML-CPP = "OFF" +ECAL_THIRDPARTY_BUILD_CURL = "OFF" +ECAL_THIRDPARTY_BUILD_HDF5 = "ON" + +build-dir = "./_python_build" + +#[tool.py-build-cmake.module] # Where to find the Python module to package +#name = "ecal" +#directory = "./lang/python" +# +#[tool.py-build-cmake.sdist] # What to include in source distributions +#include = ["CMakeLists.txt", "app/*", "cmake/*", "contrib/*", "cpack/*", "ecal/*", "lib/*", "licenses/*", "lang/python/*", "thirdparty/*"] + +#source_path = "." +#build_args = ["-j"] +#install_components = ["python_modules"] +# +#[tool.py-build-cmake.stubgen] # Whether and how to generate typed stub files diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000..d2a4b85d91 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +py-build-cmake