-
Notifications
You must be signed in to change notification settings - Fork 3
139 lines (119 loc) · 4.66 KB
/
python.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
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Build, test, and Push to PyPI
on:
[workflow_dispatch]
jobs:
build_test:
name: Build and Test
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
os: ["ubuntu-latest", "macos-13", "macos-14"] # windows fails, macos13 is x86_64 and macos-latest=14 is arm64
# monitor https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: mamba-org/setup-micromamba@v2
with:
micromamba-version: 'latest'
init-shell: >-
bash
powershell
condarc: |
channels:
- conda-forge
- name: Install build and test dependencies
shell: bash -el {0}
run: |
micromamba create -n build python=${{matrix.python-version}} pip -c conda-forge
micromamba activate build
micromamba install boost-cpp 'gudhi>=3.10' 'numpy>=2' pot 'cython>=3' pytest scikit-learn matplotlib boost joblib tqdm scipy tbb tbb-devel -c conda-forge
pip install pykeops filtration-domination --upgrade
# tbb, boost are installed in the conda env: sets some variables.
micromamba install c-compiler=1.6 cxx-compiler=1.6 -c conda-forge
- name: Build package
shell: bash -el {0}
run: |
micromamba activate build
python setup.py sdist
if [[ ${{ matrix.os }} =~ "macos-".* ]]; then
export CXXFLAGS="-fno-aligned-new" # Macos workaround
export CFLAGS="-fno-aligned-new" # Macos workaround
## should compile for both architecture
## initialize below ?
export MACOSX_DEPLOYMENT_TARGET="13.0"
# export _PYTHON_HOST_PLATFORM="macosx-13.0-universal2"
fi
if [[ ${{ matrix.os }} =~ "ubuntu-".* ]]; then
export CXXFLAGS="-march=x86-64-v3" # post haswell, for avx
export CFLAGS="-march=x86-64-v3"
fi
python setup.py build_ext -j4 --inplace bdist_wheel
- name: Fix wheels on Linux and Macos
shell: bash -el {0}
run: |
micromamba activate build
cd dist
if [[ ${{ matrix.os }} =~ "ubuntu-".* ]]; then
micromamba install auditwheel patchelf
for wheel_file in multipers*linux*.whl; do
auditwheel show $wheel_file
auditwheel repair $wheel_file --plat manylinux_2_34_x86_64
rm $wheel_file
done
fi
if [[ ${{ matrix.os }} == "macos-13" ]]; then
micromamba install delocate
for wheel_file in multipers*macosx*x86*.whl; do
delocate-listdeps $wheel_file
delocate-wheel --require-archs x86_64 -w wheelhouse -v $wheel_file
rm $wheel_file
done
fi
if [[ ${{ matrix.os }} == "macos-14" ]]; then
pip install delocate --upgrade
for wheel_file in multipers*macosx*arm64*.whl; do
delocate-listdeps $wheel_file
delocate-wheel --require-archs arm64 -w wheelhouse -v $wheel_file
rm $wheel_file
done
fi
mv wheelhouse/*.whl . # retrieves repaired wheels
cd ..
- name: Install and Test
shell: bash -el {0}
run: |
# Fresh env
micromamba create -n test python=${{matrix.python-version}} pip pytest -c conda-forge
micromamba activate test
pip install dist/*.whl --force-reinstall
pytest multipers/tests
- name: Upload sources and wheel
uses: actions/upload-artifact@v3
with:
name: sources
path: dist
send_to_pypi:
name: Send sources and wheels
runs-on: ubuntu-latest
needs: [ build_test ]
steps:
- uses: actions/download-artifact@v3
with:
name: sources
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
pip install --upgrade pip twine
twine upload --skip-existing *.tar.gz # sources
twine upload --skip-existing *.whl # wheels