Refactor third party #320
Workflow file for this run
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
name: Build | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
release: | |
types: [published] | |
jobs: | |
build_sdist: | |
name: Build sdist | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Apply patch | |
run: cd faiss && git apply ../patch/faiss-rename-swigfaiss.patch && cd .. | |
- name: Install build dependencies | |
run: python -m pip install build | |
- name: Build sdist | |
run: python -m build --sdist | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: sdist | |
path: dist/*.tar.gz | |
build_wheels: | |
name: Build wheels on ${{ matrix.os }} (${{ matrix.arch }}, ${{ matrix.opt_level }}) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
arch: auto64 | |
opt_level: avx512 | |
- os: ubuntu-latest | |
arch: aarch64 | |
opt_level: generic | |
- os: macos-latest | |
arch: auto64 | |
opt_level: avx2 | |
- os: macos-latest | |
arch: arm64 | |
opt_level: generic | |
- os: windows-latest | |
arch: auto64 | |
opt_level: generic # Upstream incompatible with AVX2 and AVX512 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Set up QEMU | |
if: runner.os == 'Linux' | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: arm64 | |
- name: Install cibuildwheel | |
run: python -m pip install cibuildwheel==2.16.2 | |
- name: Build wheels | |
run: python -m cibuildwheel --output-dir wheelhouse | |
env: | |
CIBW_ARCHS: ${{ matrix.arch }} | |
CIBW_ENVIRONMENT_LINUX: > | |
FAISS_OPT_LEVEL=${{ matrix.opt_level }} | |
FAISS_ENABLE_GPU=OFF | |
CIBW_ENVIRONMENT_MACOS: > | |
FAISS_OPT_LEVEL=${{ matrix.opt_level }} | |
TARGET_ARCH=${{ matrix.arch }} | |
LIBOMP_USE_HIDDEN_HELPER_TASK=0 | |
LIBOMP_NUM_HIDDEN_HELPER_THREADS=0 | |
MACOSX_DEPLOYMENT_TARGET=10.14 | |
CIBW_ENVIRONMENT_WINDOWS: > | |
FAISS_OPT_LEVEL=${{ matrix.opt_level }} | |
CMAKE_PREFIX_PATH="c:\\opt" | |
PATH="${PATH};${CONDA}\\condabin;${CONDA}\\Library\\bin" | |
LIB="${LIB};${CMAKE_PREFIX_PATH}\\lib;${CONDA}\\Library\\lib" | |
CPATH="${CPATH};${CMAKE_PREFIX_PATH}\\include;${CONDA}\\Library\\include" | |
CIBW_BEFORE_ALL: bash scripts/build_${{ runner.os }}.sh | |
CIBW_BEFORE_TEST_LINUX: pip install torch --index-url https://download.pytorch.org/whl/cpu | |
CIBW_TEST_COMMAND: > | |
env -u FAISS_OPT_LEVEL pytest {project}/faiss/tests && | |
env -u FAISS_OPT_LEVEL pytest {project}/faiss/tests/torch_test_contrib.py | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: wheel-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.opt_level }} | |
path: ./wheelhouse/*.whl | |
publish: | |
name: Upload packages to PyPI | |
needs: [build_sdist, build_wheels] | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
if: github.event_name == 'release' && github.event.action == 'published' | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
path: dist | |
- uses: pypa/gh-action-pypi-publish@release/v1 |