Skip to content

Commit

Permalink
First shot at creating eCAL wheels through py-build-cmake.
Browse files Browse the repository at this point in the history
  • Loading branch information
KerstinKeller committed Aug 10, 2023
1 parent 5ef1c46 commit 65c3e5d
Show file tree
Hide file tree
Showing 29 changed files with 122 additions and 428 deletions.
18 changes: 3 additions & 15 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
-DBUILD_APPS=ON \
-DBUILD_SAMPLES=ON \
-DBUILD_TIME=ON \
-DBUILD_PY_BINDING=ON \
-DBUILD_PY_BINDING=OFF \
-DBUILD_CSHARP_BINDING=OFF \
-DBUILD_ECAL_TESTS=ON \
-DECAL_INCLUDE_PY_SAMPLES=OFF \
Expand All @@ -86,9 +86,7 @@ jobs:
-DECAL_THIRDPARTY_BUILD_YAML-CPP=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON \
-DPython_FIND_STRATEGY=LOCATION \
-DPython_FIND_REGISTRY=NEVER
-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON
sudo mkdir /etc/ecal
sudo cp "$GITHUB_WORKSPACE/ecal/core/cfg/ecal.ini" /etc/ecal
shell: bash
Expand All @@ -97,10 +95,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
Expand All @@ -122,10 +116,4 @@ jobs:
uses: actions/upload-artifact@v3
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
path: ${{ runner.workspace }}/_build/_deploy/*.dmg
44 changes: 2 additions & 42 deletions .github/workflows/build-ubuntu-20.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
-DBUILD_APPS=ON \
-DBUILD_SAMPLES=ON \
-DBUILD_TIME=ON \
-DBUILD_PY_BINDING=ON \
-DBUILD_PY_BINDING=OFF \
-DBUILD_STANDALONE_PY_WHEEL=ON \
-DBUILD_CSHARP_BINDING=OFF \
-DBUILD_ECAL_TESTS=ON \
Expand All @@ -92,8 +92,7 @@ jobs:
-DCMAKE_INSTALL_SYSCONFDIR=/etc \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LOCALSTATEDIR=/var \
-DCMAKE_INSTALL_LIBDIR=lib/x86_64-linux-gnu \
-DPython_FIND_VIRTUALENV=ONLY
-DCMAKE_INSTALL_LIBDIR=lib/x86_64-linux-gnu
sudo mkdir /etc/ecal
sudo cp "$GITHUB_WORKSPACE/ecal/core/cfg/ecal.ini" /etc/ecal
Expand All @@ -103,39 +102,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
Expand All @@ -150,12 +116,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
Expand Down
44 changes: 2 additions & 42 deletions .github/workflows/build-ubuntu-22.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
-DBUILD_APPS=ON \
-DBUILD_SAMPLES=ON \
-DBUILD_TIME=ON \
-DBUILD_PY_BINDING=ON \
-DBUILD_PY_BINDING=OFF \
-DBUILD_STANDALONE_PY_WHEEL=ON \
-DBUILD_CSHARP_BINDING=OFF \
-DBUILD_ECAL_TESTS=ON \
Expand All @@ -92,8 +92,7 @@ jobs:
-DCMAKE_INSTALL_SYSCONFDIR=/etc \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LOCALSTATEDIR=/var \
-DCMAKE_INSTALL_LIBDIR=lib/x86_64-linux-gnu \
-DPython_FIND_VIRTUALENV=ONLY
-DCMAKE_INSTALL_LIBDIR=lib/x86_64-linux-gnu
sudo mkdir /etc/ecal
sudo cp "$GITHUB_WORKSPACE/ecal/core/cfg/ecal.ini" /etc/ecal
Expand All @@ -103,39 +102,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
Expand All @@ -149,9 +115,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
85 changes: 1 addition & 84 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ^
Expand Down Expand Up @@ -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.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 Python 3.6 Wheel
run: |
mkdir ".venv_36"
py -3.6 -m venv ".venv_36"
CALL ".venv_36\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
Expand Down Expand Up @@ -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
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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, macos-11]

steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
fetch-depth: 0

- name: Build wheels
uses: pypa/cibuildwheel@v2.15.0
# env:
# CIBW_SOME_OPTION: value
# ...
# with:
# package-dir: .
# output-dir: wheelhouse
# config-file: "{package}/pyproject.toml"

- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,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})
Expand Down
42 changes: 0 additions & 42 deletions lang/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 65c3e5d

Please sign in to comment.