chore: unify build system into pyproject.toml #37
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
# yamllint disable rule:line-length | |
name: Build distribution | |
on: # yamllint disable-line rule:truthy | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
- main | |
- dev | |
- release* | |
tags: | |
- v* | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
sdist: | |
name: Build source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- uses: astral-sh/setup-uv@v5 | |
- name: Build sdist | |
run: | | |
uv build --sdist | |
- uses: actions/upload-artifact@v4 | |
name: Upload build artifacts | |
with: | |
name: sdist | |
path: 'dist/*.tar.gz' | |
manylinux: | |
needs: [sdist] | |
name: 'Build wheels' | |
runs-on: ${{ matrix.os }} | |
env: | |
LIBROCKSDB_PATH: /opt/rocksdb-${{ matrix.rocksdb_ver }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
rocksdb_ver: ['8.11.fb'] | |
steps: | |
- uses: actions/checkout@v4 | |
name: Checkout source repository | |
- uses: actions/setup-python@v5 | |
name: Set up Python 3.12 | |
with: | |
python-version: 3.12 | |
- name: Install cibuildwheel | |
run: | | |
python3 -m pip install cibuildwheel==1.7.1 | |
- name: Build wheels | |
run: | | |
python3 -m cibuildwheel --output-dir dist | |
env: | |
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 | |
CIBW_BUILD: 'cp31*' | |
CIBW_SKIP: '*-manylinux_i686' | |
# Install python package and test-deps. | |
CIBW_TEST_REQUIRES: '.[test] pytest' | |
# Use `--pyargs` to interpret parameter as module to import, not as a | |
# path, and do not use `python3 -m pytest`. This way we prevent | |
# importing the module from the current directory instead of the | |
# installed package, and failing when it cannot find the shared | |
# library. | |
CIBW_TEST_COMMAND: 'pytest --pyargs rocksdb' | |
# Avoid re-building the C library in every iteration by testing for | |
# the build directory. | |
CIBW_BEFORE_BUILD: > | |
yum install -y snappy snappy-devel zlib zlib-devel bzip2 bzip2-devel lz4-devel libzstd-devel && | |
test -d ${{ env.LIBROCKSDB_PATH }} || ( | |
git clone https://github.com/facebook/rocksdb --depth 1 | |
--branch ${{ matrix.rocksdb_ver }} ${{ env.LIBROCKSDB_PATH }} && | |
cd ${{ env.LIBROCKSDB_PATH }} && | |
CXXFLAGS='-flto -Os -s' PORTABLE=1 make shared_lib -j 4 | |
) && | |
pushd ${{ env.LIBROCKSDB_PATH }} && | |
make install-shared && | |
ldconfig && | |
popd | |
- uses: actions/upload-artifact@v4 | |
name: Upload build artifacts | |
with: | |
path: 'dist/*.whl' | |
# publish: | |
# name: Upload packages | |
# needs: [manylinux, sdist] | |
# runs-on: 'ubuntu-latest' | |
# if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') | |
# steps: | |
# - uses: actions/download-artifact@v4 | |
# name: 'Download artifacts' | |
# with: | |
# name: 'artifact' | |
# path: 'dist' | |
# | |
# - uses: pypa/gh-action-pypi-publish@master | |
# name: 'Publish built packages' | |
# with: | |
# user: '__token__' | |
# password: '${{ secrets.PYPI_API_TOKEN }}' |