-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1721 from BDoignies/GHActionsPython
Gh actions for python
- Loading branch information
Showing
47 changed files
with
428 additions
and
844 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.