-
-
Notifications
You must be signed in to change notification settings - Fork 120
170 lines (141 loc) · 5.48 KB
/
pythonBindings-Pypi.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
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: -DWITH_OPENMP=true -DENABLE_CONAN=true -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe"
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]
python-version: ["3.9", "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 dependencies (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 dependencies (macOS)
if: matrix.os == 'macOS-latest'
run: brew install boost ninja gmp libomp ccache cgal
- name: Install dependencies (conan - Windows 1/2)
if: matrix.os == 'windows-latest'
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 2.4.0
- name: Install dependencies (conan - Windows 2/2)
if: matrix.os == 'windows-latest'
run: |
conan profile detect --force
- uses: actions/cache@v3
if: matrix.os == 'windows-latest'
with:
path: ~/.conan2
key: ${{ runner.os }}-conan2-${{ matrix.BUILD_TYPE }}
- name: Install python dependencies
shell: bash
run: |
python -m pip install cmake
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: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build
- name: Deps on Windows
if: matrix.os == 'windows-latest'
shell: bash
working-directory: ${{runner.workspace}}/build
run: |
conan install $GITHUB_WORKSPACE --build=missing
cmake $GITHUB_WORKSPACE -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=${{ matrix.BUILD_TYPE }} $CONFIG_PYTHON $CONFIG_GLOBAL $CONFIG_WINDOWS
- 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 }}
- 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