Skip to content

Commit

Permalink
Try to build python wheels with scikit-build-core.
Browse files Browse the repository at this point in the history
  • Loading branch information
KerstinKeller committed Dec 13, 2023
1 parent 210d236 commit 41e572c
Show file tree
Hide file tree
Showing 22 changed files with 206 additions and 578 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
39 changes: 0 additions & 39 deletions .github/workflows/build-ubuntu-20.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
39 changes: 0 additions & 39 deletions .github/workflows/build-ubuntu-22.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
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.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
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
36 changes: 36 additions & 0 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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})
Expand Down
6 changes: 3 additions & 3 deletions app/app_pb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading

0 comments on commit 41e572c

Please sign in to comment.