Switch to upstream Python SWIG bindings #47
This file contains hidden or 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: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build wheel | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Set up Python | |
| run: uv python install 3.12 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libssl-dev libxml2-dev zlib1g-dev flatbuffers-compiler libflatbuffers-dev | |
| - name: Build wheel | |
| run: uv build --wheel | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: wheel | |
| path: dist/*.whl | |
| test: | |
| name: Test | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Set up Python | |
| run: uv python install 3.12 | |
| - name: Download wheel | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: wheel | |
| path: dist | |
| - name: Install wheel and test | |
| run: | | |
| uv venv | |
| uv pip install dist/*.whl pytest cryptography | |
| uv run --no-project pytest tests/ -v | |
| build_wheels: | |
| name: Build wheels on ${{ matrix.os }} | |
| if: github.event_name == 'release' || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Install dependencies (Ubuntu) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libssl-dev libxml2-dev zlib1g-dev | |
| - name: Install dependencies (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install openssl@3 libxml2 flatbuffers cmake swig | |
| - name: Install dependencies (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| vcpkg install openssl:x64-windows zlib:x64-windows libxml2:x64-windows flatbuffers:x64-windows | |
| - name: Build wheels | |
| uses: pypa/cibuildwheel@v3.3.1 | |
| env: | |
| # Use uv for faster builds | |
| CIBW_BUILD_FRONTEND: "build[uv]" | |
| # Build for Python 3.10-3.14 | |
| CIBW_BUILD: "cp310-* cp311-* cp312-* cp313-* cp314-*" | |
| # Skip 32-bit builds and musllinux | |
| CIBW_SKIP: "*-win32 *-manylinux_i686 *-musllinux_*" | |
| # Use manylinux_2_28 for GCC 13 (C++23 support) | |
| CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 | |
| CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28 | |
| # Install build dependencies in the container (need GCC 13 for C++23, OpenSSL 3.x) | |
| CIBW_BEFORE_ALL_LINUX: > | |
| dnf install -y gcc-toolset-13 perl-IPC-Cmd perl-Time-Piece libxml2-devel zlib-devel && | |
| source /opt/rh/gcc-toolset-13/enable && | |
| curl -L https://www.openssl.org/source/openssl-3.0.19.tar.gz | tar xz && | |
| cd openssl-3.0.19 && | |
| ./config --prefix=/usr/local/openssl3 --openssldir=/usr/local/openssl3 && | |
| make -j$(nproc) && | |
| make install_sw install_ssldirs | |
| CIBW_ENVIRONMENT_LINUX: > | |
| CC=/opt/rh/gcc-toolset-13/root/usr/bin/gcc | |
| CXX=/opt/rh/gcc-toolset-13/root/usr/bin/g++ | |
| OPENSSL_ROOT_DIR=/usr/local/openssl3 | |
| PKG_CONFIG_PATH=/usr/local/openssl3/lib64/pkgconfig | |
| PATH=/opt/rh/gcc-toolset-13/root/usr/bin:$PATH | |
| LD_LIBRARY_PATH=/usr/local/openssl3/lib64:/usr/local/openssl3/lib:/opt/rh/gcc-toolset-13/root/usr/lib64:$LD_LIBRARY_PATH | |
| # Install flatbuffers from source on Linux | |
| CIBW_BEFORE_BUILD_LINUX: > | |
| uv pip install --system cmake swig && | |
| if ! command -v flatc; then | |
| cd /tmp && | |
| curl -L https://github.com/google/flatbuffers/archive/refs/tags/v25.12.19.tar.gz | tar xz && | |
| cd flatbuffers-25.12.19 && | |
| cmake -B build -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF && | |
| cmake --build build --target install; | |
| fi | |
| # cmake and swig installed via brew in Install dependencies step | |
| CIBW_BEFORE_BUILD_WINDOWS: uv pip install --system cmake swig delvewheel | |
| # Set vcpkg toolchain for Windows | |
| CIBW_ENVIRONMENT_WINDOWS: > | |
| CMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake | |
| # Set OpenSSL path on macOS; Homebrew OpenSSL requires macOS 15+ | |
| CIBW_ENVIRONMENT_MACOS: > | |
| OPENSSL_ROOT_DIR=/opt/homebrew/opt/openssl@3 | |
| CMAKE_PREFIX_PATH=/opt/homebrew | |
| MACOSX_DEPLOYMENT_TARGET=15.0 | |
| # Repair wheels (bundle native dependencies) | |
| CIBW_REPAIR_WHEEL_COMMAND_LINUX: auditwheel repair -w {dest_dir} {wheel} | |
| CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-wheel -w {dest_dir} {wheel} | |
| CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: delvewheel repair --add-path C:/vcpkg/installed/x64-windows/bin -w {dest_dir} {wheel} | |
| # Test the wheel | |
| CIBW_TEST_REQUIRES: pytest | |
| CIBW_TEST_COMMAND: pytest {project}/tests -v | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: wheels-${{ matrix.os }} | |
| path: ./wheelhouse/*.whl | |
| build_sdist: | |
| name: Build source distribution | |
| if: github.event_name == 'release' || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Build sdist | |
| run: uv build --sdist | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: sdist | |
| path: dist/*.tar.gz | |
| publish: | |
| name: Publish to PyPI | |
| needs: [build_wheels, build_sdist] | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' && github.event.action == 'published' | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/pycdoc | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/download-artifact@v7 | |
| with: | |
| pattern: wheels-* | |
| path: dist | |
| merge-multiple: true | |
| - uses: actions/download-artifact@v7 | |
| with: | |
| name: sdist | |
| path: dist | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |