repair build on newer M1/2/3 macs (#265) #297
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
# Build python bindings | |
name: Build python bindings | |
# Controls when the action will run. | |
on: | |
# Triggers the workflow on push or pull request events but only for the master branch | |
push: | |
pull_request: | |
branches: [ master ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ${{matrix.os}} | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ] | |
os: [ 'macos-latest', 'ubuntu-22.04' ] | |
include: | |
# test sdist on ubuntu only | |
- os: ubuntu-22.04 | |
python-version: '3.11' | |
sdist: true | |
build_direct: true | |
name: Python ${{ matrix.python-version }} on ${{ matrix.os }} build | |
steps: | |
- name: install Linux deps | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libsnappy-dev libzzip-dev zlib1g-dev libboost-all-dev | |
sudo apt-get install ccache | |
- name: install macOS deps | |
if: runner.os == 'macOS' | |
run: | | |
brew update | |
brew install zlib snappy boost | |
brew install ccache | |
- name: checkout from git | |
uses: actions/checkout@v2 | |
- name: ccache | |
uses: hendrikmuhs/[email protected] | |
with: | |
key: ${{ matrix.os }}-python | |
- name: Setup python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: x64 | |
- name: Install python dependencies | |
run: | | |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | |
python -m pip install -r python/requirements.txt | |
- name: build and test python extension | |
if: matrix.build_direct | |
run: | | |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | |
cd python | |
python setup.py build --mode Release | |
python setup.py install --user | |
python -m pytest tests | |
python -m pytest integration-tests | |
python -m pip uninstall -y keyvi | |
- name: bdist | |
run: | | |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | |
cd python | |
python setup.py bdist_wheel -d wheelhouse | |
- name: delocate | |
if: runner.os == 'macOS' | |
run: | | |
cd python | |
delocate-listdeps wheelhouse/keyvi*.whl | |
delocate-wheel wheelhouse/keyvi*.whl | |
delocate-listdeps wheelhouse/keyvi*.whl | |
- name: remove macos deps | |
if: runner.os == 'macOS' | |
run: | | |
brew remove zlib | |
brew remove --ignore-dependencies snappy | |
- name: bdist test | |
run: | | |
cd python | |
python -m pip install --user wheelhouse/*.whl | |
python -m pytest tests | |
python -m pip uninstall -y keyvi | |
- name: sdist | |
if: matrix.sdist | |
run: | | |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | |
cd python | |
rm -rf wheelhouse | |
python setup.py sdist -d wheelhouse | |
python -m pip uninstall -y autowrap | |
python -m pip install wheelhouse/*.tar.gz -v | |
python -m pytest tests | |
python -m pip uninstall -y keyvi | |
- name: Publish package | |
if: ( matrix.sdist || runner.os == 'macOS' ) && github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
env: | |
PYPI_PASSWORD: ${{ secrets.pypi_password }} | |
run: | | |
python -m twine upload -u __token__ -p "${PYPI_PASSWORD}" python/wheelhouse/* |