Skip to content

Commit

Permalink
Merge pull request #1721 from BDoignies/GHActionsPython
Browse files Browse the repository at this point in the history
Gh actions for python
  • Loading branch information
dcoeurjo authored May 23, 2024
2 parents 6ac712c + 9e873c0 commit 72e0379
Show file tree
Hide file tree
Showing 47 changed files with 428 additions and 844 deletions.
112 changes: 112 additions & 0 deletions .github/workflows/pythonBindings-PR.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: CI Python bindings (linux/macOS/windows)

on:
pull_request:
branches: [ master ]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
TESTBLACKLIST: "(testLinearStructure|testIntegerConverter|testArithmeticalDSSComputerOnSurfels)"
CONFIG_GLOBAL: -DBUILD_EXAMPLES=false -DBUILD_TESTING=false -DWITH_EIGEN=true
CONFIG_PYTHON: -DDGTAL_WRAP_PYTHON=ON -DDGTAL_BUILD_TESTING_PYTHON=ON
CONFIG_LINUX:
CONFIG_MAC:
CONFIG_WINDOWS: -DWITH_OPENMP=true -DENABLE_CONAN=true -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe"

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
python-version: ["3.11"]
BUILD_TYPE: [Release]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Installing dependancies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install zsh libqglviewer-dev-qt5 libboost-dev libcgal-dev ninja-build libhdf5-serial-dev libboost-dev libcairo2-dev libgmp-dev libfftw3-dev libinsighttoolkit4-dev xorg-dev libglu1-mesa-dev freeglut3-dev mesa-common-dev
- name: Installing dependancies (macOS)
if: matrix.os == 'macOS-latest'
run: brew install boost ninja gmp libomp ccache cgal

- name: Install dependancies (conan - Windows 1/2)
if: matrix.os == 'windows-latest'
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 1.57.0

- name: Install dependancies (conan - Windows 2/2)
if: matrix.os == 'windows-latest'
run: conan profile new default --detect

- uses: actions/cache@v3
if: matrix.os == 'windows-latest'
with:
path: ~/.conan
key: ${{ runner.os }}-conan-${{ matrix.BUILD_TYPE }}


- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Configure CMake (Linux)
if: matrix.os == 'ubuntu-latest'
shell: bash
working-directory: ${{runner.workspace}}/build
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.BUILD_TYPE }} $CONFIG_PYTHON $CONFIG_GLOBAL $CONFIG_LINUX -G Ninja

- name: Configure CMake (macOS)
if: matrix.os == 'macOS-latest'
shell: bash
working-directory: ${{runner.workspace}}/build
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.BUILD_TYPE }} $CONFIG_PYTHON $CONFIG_GLOBAL $CONFIG_MAC -G Ninja

- name: Configure CMake (Windows)
if: matrix.os == 'windows-latest'
shell: bash
working-directory: ${{runner.workspace}}/build
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.BUILD_TYPE }} $CONFIG_PYTHON $CONFIG_GLOBAL $CONFIG_WINDOWS


- name: Build
shell: bash
working-directory: ${{runner.workspace}}/build
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config ${{ matrix.BUILD_TYPE }} --parallel 8

- name: Import module Test
shell: bash
working-directory: ${{runner.workspace}}/build
run: |
python -c "import dgtal"
- name: Install python dependancies
shell: bash
run: |
python -m pip install pytest
python -m pip install numpy
python -m pip install itk
- name: Run unit tests
shell: bash
working-directory: ${{runner.workspace}}/build
run: |
ctest -R python -C ${{ matrix.BUILD_TYPE }} -V --output-on-failure
159 changes: 159 additions & 0 deletions .github/workflows/pythonBindings-Pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
name: Deploying to pypi (linux/macOS/windows)

on:
push:
tags:
- '*' # TODO: set filter here if multiple tags are required

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
TESTBLACKLIST: "(testLinearStructure|testIntegerConverter|testArithmeticalDSSComputerOnSurfels)"
# No options, setup.py already has it all !
CONFIG_GLOBAL:
CONFIG_LINUX:
CONFIG_MAC:
CONFIG_WINDOWS:

jobs:
build:
if: startsWith(github.ref, 'refs/tags/') # Only if tagged
runs-on: ${{ matrix.os }}
environment: deploy
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
python-version: ["3.10", "3.11"]
BUILD_TYPE: [Release]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Installing dependancies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install zsh libqglviewer-dev-qt5 libboost-dev libcgal-dev ninja-build libhdf5-serial-dev libboost-dev libcairo2-dev libgmp-dev libfftw3-dev libinsighttoolkit4-dev xorg-dev libglu1-mesa-dev freeglut3-dev mesa-common-dev
- name: Installing dependancies (macOS)
if: matrix.os == 'macOS-latest'
run: brew install boost ninja gmp libomp ccache cgal

- name: Install dependancies (conan - Windows 1/2)
if: matrix.os == 'windows-latest'
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 1.57.0

- name: Install dependancies (conan - Windows 2/2)
if: matrix.os == 'windows-latest'
run: conan profile new default --detect

- uses: actions/cache@v3
if: matrix.os == 'windows-latest'
with:
path: ~/.conan
key: ${{ runner.os }}-conan-${{ matrix.BUILD_TYPE }}

- name: Install python dependancies
shell: bash
run: |
python -m pip install cmake
python -m pip install ninja
python -m pip install delocate
python -m pip install scikit-build
- name: Setting build informations (Linux)
if: matrix.os == 'ubuntu-latest'
shell: bash
working-directory: wrap/deploy
run: |
sed -i "1s/.*/VERSION = '${{ github.ref_name }}'/" dgtalVersion.py
cat dgtalVersion.py
- name: Setting build informations (Mac os)
if: matrix.os == 'macOS-latest'
shell: bash
working-directory: wrap/deploy
run: |
# Note the emtpy strings required on macos !
sed -i '' "1s/.*/VERSION = '${{ github.ref_name }}'/" dgtalVersion.py
cat dgtalVersion.py
- name: Setting build informations (Windows)
if: matrix.os == 'windows-latest'
shell: bash
working-directory: wrap/deploy
run: |
sed -i "1s/.*/VERSION = '${{ github.ref_name }}'/" dgtalVersion.py
cat dgtalVersion.py
- name: Building whl
shell: bash
working-directory: wrap/deploy
run: |
python setup.py bdist_wheel --build-type ${{ matrix.BUILD_TYPE }} -G Ninja
- name: Verifying wheel (Install - 1/2)
shell: bash
working-directory: wrap/deploy
run: |
python -m pip install dist/* # Naming would be complicated...
- name: Verifying wheel (Install - 2/2)
shell: bash
working-directory: wrap/tests
run: |
python -m pip install pytest
pytest .
- name: Repairing Linux Wheel (autitwheel - linux -> manylinux)
if: matrix.os == 'ubuntu-latest'
shell: bash
working-directory: wrap/deploy
run: |
python -m pip install auditwheel
sudo apt-get install patchelf
auditwheel repair -w dist/ --plat manylinux_2_35_x86_64 dist/* # Add shared libraries to .whl
rm dist/*-linux_$(uname -p).whl # Removes shared lib before upload
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: wrap/deploy/dist/

publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
if: startsWith(github.ref, 'refs/tags/')
needs:
- build
runs-on: ubuntu-latest

environment:
name: deploy-pypi
url: https://pypi.org/p/dgtal

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/

- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1


1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ Robin Lamy <robin.lamy1@grenoble-inp.org>
Baptiste GENEST <baptistegenest@gmail.com>
Jeremy Fix <https://github.com/jeremyfix>
Colin Weill--Duflos <colin.weill-duflos@univ-smb.fr>
Bastien Doignies <bastien.doignies@liris.cnrs.fr>
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
- *General*
- Renaming AUTHORS→CONTRIBUTORS for HAL (David Coeurjolly,
[#1699](https://github.com/DGtal-team/DGtal/pull/1699))
- Python bindings and Pypi deploy are now handled by Github-Actions (Bastien Doignies,
[#1721](https://github.com/DGtal-team/DGtal/pull/1721))

- *IO*
- New method to change the mode of the light position in Viewer3D (fixed to
Expand Down
Loading

0 comments on commit 72e0379

Please sign in to comment.