Skip to content

potential fix for macos arm #88

potential fix for macos arm

potential fix for macos arm #88

Workflow file for this run

# 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:
push:
jobs:
build_test:
name: Build and Test
# container: gudhi/pip_for_gudhi:latest # container allows to compile for older abis, but is not easy to setup...
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
os: ["ubuntu-latest", "macos-latest"] #windows fails for some reasons
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup miniconda
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
activate-environment: build_test_env
channels: conda-forge
# channel-priority: true
- name: Install build and test dependencies
shell: bash -el {0}
run: |
conda install mamba -c conda-forge
mamba install python=${{matrix.python-version}} pip -c conda-forge
mamba install numpy gudhi cython boost boost-cpp tbb tbb-devel pytest scikit-learn matplotlib build cxx-compiler joblib tqdm scipy -c conda-forge
pip install pykeops filtration-domination --upgrade
- name: Build package
shell: bash -el {0}
run: |
if [[ ${{ matrix.os }} == "macos-latest" ]]; then
export CXXFLAGS="-march=generic -mtune=generic -fno-aligned-new $CXXFLAGS" # Macos workaround
export CFLAGS="-march=generic -mtune=generic-fno-aligned-new $CFLAGS" # Macos workaround
## should compile for both architecture
export MACOSX_DEPLOYMENT_TARGET="11.7"
export _PYTHON_HOST_PLATFORM="macosx-11.7-universal2"
export ARCHFLAGS="-arch arm64 -arch x86_64"
fi
python setup.py sdist
python setup.py build_ext -j2 --inplace # Parallel compilation, compatible with macos
pip wheel . --wheel-dir dist
- name: Install and Test
shell: bash -el {0}
run: |
pip install dist/*.whl
pytest multipers/tests
- name: Fix wheels on Linux and Macos
shell: bash -el {0}
run: |
if [[ ${{ matrix.os }} == "ubuntu-latest" ]]; then
cd dist
pip install auditwheel --upgrade
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
mv wheelhouse/*.whl . # retrieves repaired wheels
cd ..
fi
if [[ ${{ matrix.os }} == "macos-latest" ]]; then
cd dist
pip install delocate --upgrade
for wheel_file in multipers*macosx*.whl; do
delocate-listdeps $wheel_file
delocate-wheel --require-archs universal2 -w wheelhouse -v $wheel_file
rm $wheel_file
done
mv wheelhouse/*.whl . # retrieves repaired wheels
cd ..
fi
- 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