Skip to content

Commit 7576eb9

Browse files
ulupoMonkeyBreaker
andauthored
Add @MonkeyBreaker's GitHub action for wheel building (#646)
* Merge with latest master, do not delete Azure CI, remove Py36, add Py310 and Apple Silicon * Enable cross-compilation on macOS as done by @MonkeyBreaker in pyflagser and giotto-ph * Linting in test_rips_complex * Bump install-boost version to 2.3.1 (latest) * Bumping cibuildwheel version to 2.9.0 (latest) Co-authored-by: julian <[email protected]>
1 parent 12aa80e commit 7576eb9

File tree

5 files changed

+111
-7
lines changed

5 files changed

+111
-7
lines changed

.github/workflows/wheels.yml

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Build Wheels
2+
3+
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_dispatchinputs
4+
on :
5+
workflow_dispatch:
6+
inputs:
7+
nightlyRelease:
8+
description: 'Generates wheels for the nightly release'
9+
type: boolean
10+
required: true
11+
default: false
12+
13+
jobs:
14+
15+
build_wheels:
16+
name: Build wheels on ${{ matrix.os }}
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
os: [ubuntu-latest, windows-latest, macos-latest]
22+
include:
23+
- os: ubuntu-latest
24+
boost_install_dir: /home/runner/work
25+
- os: macos-latest
26+
boost_install_dir: /Users/runner/work
27+
- os: windows-latest
28+
boost_install_dir: D:\
29+
env:
30+
BOOST_VERSION: 1.76.0
31+
32+
steps:
33+
- uses: actions/checkout@v2
34+
35+
- name: Change name to giotto-tda-nightly
36+
if: ${{ github.event.inputs.nightlyRelease == true }}
37+
run: |
38+
set -e
39+
sed -i "s/'giotto-tda'/'giotto-tda-nightly'/1" setup.py
40+
sed -i 's/"giotto-tda"/"giotto-tda-nightly"/1' setup.py
41+
sed -i "s/__version__.*/__version__ = '$(Build.BuildNumber)'/1" gtda/_version.py
42+
shell: bash
43+
44+
- name: Create directories boost
45+
run: |
46+
cd ${{ matrix.boost_install_dir }}
47+
mkdir -p boost/boost
48+
cd -
49+
50+
- name: Cache boost ${{env.BOOST_VERSION}} in ${{ matrix.boost_install_dir }}
51+
# FIXME For an unknown reason on windows runner, when the cache is hit
52+
# The compilation fails because it doesn't find some headers
53+
# I don't know if the cache is corrupted, for the moment hard to debug
54+
if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
55+
uses: actions/cache@v2
56+
id: cache-boost
57+
with:
58+
# Set the default path as the path to cache
59+
path: ${{ matrix.boost_install_dir }}/boost/boost
60+
# Use the version as the key to only cache the correct version
61+
key: 1-boost-${{env.BOOST_VERSION}}
62+
63+
- name: Install boost ${{env.BOOST_VERSION}}
64+
uses: MarkusJx/[email protected]
65+
id: install-boost
66+
if: steps.cache-boost.outputs.cache-hit != 'true'
67+
with:
68+
boost_version: ${{env.BOOST_VERSION}}
69+
boost_install_dir: ${{ matrix.boost_install_dir }}
70+
71+
- name: Build wheels
72+
uses: pypa/[email protected]
73+
env:
74+
# Specify which Python versions to build wheels
75+
# https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip
76+
CIBW_BUILD: "cp37-* cp38-* cp39-* cp310-*"
77+
# Skip 32 bit architectures, musllinux, and i686, and macOS x86_64 wheels for CP3.8 -- CP3.10
78+
CIBW_SKIP: "*-win32 *-musllinux_x86_64 *_i686 cp38-macosx_x86_64 cp39-macosx_x86_64 cp310-macosx_x86_64"
79+
CIBW_BEFORE_BUILD_WINDOWS: python -m pip install cmake && python -m pip install --upgrade pip setuptools && sed -i $'s/\r$//' README.rst && python -m pip install delvewheel
80+
CIBW_BEFORE_BUILD_LINUX: python -m pip install cmake && python -m pip install --upgrade pip setuptools
81+
CIBW_BEFORE_BUILD_MACOS: python -m pip install cmake && python -m pip install --upgrade pip setuptools
82+
CIBW_TEST_COMMAND: python -m pytest --pyargs gtda
83+
# nbformat is needed by plotly: https://github.com/plotly/plotly.py/issues/2159
84+
CIBW_TEST_REQUIRES: pytest hypothesis pandas nbformat
85+
CIBW_ENVIRONMENT_WINDOWS: BOOST_ROOT='${{ matrix.boost_install_dir }}boost\boost'
86+
CIBW_ENVIRONMENT_MACOS: BOOST_ROOT='${{ matrix.boost_install_dir }}/boost'
87+
CIBW_ENVIRONMENT_LINUX: BOOST_ROOT=/host${{ matrix.boost_install_dir }}/boost
88+
CIBW_ENVIRONMENT_PASS_LINUX: BOOST_ROOT
89+
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -vv -w {dest_dir} {wheel}"
90+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
91+
# Should generate universal2 wheels for CP3.8 -- CP3.10
92+
CIBW_ARCHS_MACOS: x86_64 universal2
93+
94+
- uses: actions/upload-artifact@v2
95+
name: Upload wheels
96+
with:
97+
path: ./wheelhouse/*.whl

doc/contributing/index.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ Contributing
66

77
This page contains a summary of what one needs to do to contribute.
88

9-
..
10-
toctree::
9+
.. toctree::
1110
:maxdepth: 2
1211
:hidden:
1312

gtda/externals/__init__.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33

44
from .modules.gtda_bottleneck import bottleneck_distance
55
from .modules.gtda_wasserstein import wasserstein_distance
6-
from .python import SparseRipsComplex, CechComplex, CubicalComplex, \
7-
PeriodicCubicalComplex, SimplexTree, WitnessComplex, StrongWitnessComplex
6+
from .python import RipsComplex, SparseRipsComplex, CechComplex, \
7+
CubicalComplex, PeriodicCubicalComplex, SimplexTree, WitnessComplex, \
8+
StrongWitnessComplex
89

910
__all__ = [
1011
'bottleneck_distance',
1112
'wasserstein_distance',
13+
'RipsComplex',
1214
'SparseRipsComplex',
1315
'CechComplex',
1416
'CubicalComplex',

gtda/externals/python/tests/test_rips_complex.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
from .. import RipsComplex, SparseRipsComplex
22

3-
""" Test comes from
3+
"""Test comes from
44
https://github.com/GUDHI/gudhi-devel/blob/master/src/python/test/test_rips_complex.py
5-
65
"""
76

87

98
def test_empty_rips():
109
rips_complex = RipsComplex()
11-
del(rips_complex)
10+
del rips_complex
1211

1312

1413
def test_sparse_filtered_rips_from_points():

setup.py

+7
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ def build_extension(self, ext):
129129
cmake_args += [f"-DCMAKE_BUILD_TYPE={cfg}"]
130130
build_args += ["--", "-j2"]
131131

132+
if sys.platform.startswith("darwin"):
133+
# Cross-compile support for macOS - respect ARCHFLAGS if set
134+
archs = re.findall(r"-arch (\S+)", os.environ.get("ARCHFLAGS", ""))
135+
if archs:
136+
cmake_args += \
137+
["-DCMAKE_OSX_ARCHITECTURES={}".format(";".join(archs))]
138+
132139
env = os.environ.copy()
133140
env["CXXFLAGS"] = f"{env.get('CXXFLAGS', '')} -DVERSION_INFO="\
134141
f"\\'{self.distribution.get_version()}\\'"

0 commit comments

Comments
 (0)