Add basic-cython example (#52) #284
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: Test and build wheels | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.8", "3.14"] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install and run tests | |
| run: | | |
| pip install -e ".[dev]" | |
| pytest tests/ -v | |
| build-with-profile: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - runner: ubuntu-latest | |
| profile: linux.jinja | |
| py: "3.10.19" | |
| - runner: ubuntu-latest | |
| profile: linux.jinja | |
| py: "3.14.2" | |
| - runner: macos-14 | |
| profile: macos.jinja | |
| py: "3.10.19" | |
| - runner: macos-14 | |
| profile: macos.jinja | |
| py: "3.14.2" | |
| - runner: windows-latest | |
| profile: windows.jinja | |
| py: "3.10.19" | |
| - runner: windows-latest | |
| profile: windows.jinja | |
| py: "3.14.2" | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Conan and detect profile | |
| run: | | |
| pip install conan | |
| conan profile detect --force | |
| - name: Create cpython-portable (${{ matrix.py }}) | |
| run: conan create recipes/cpython --version=${{ matrix.py }} | |
| shell: bash | |
| - name: Install backend | |
| run: pip install -e . | |
| - name: Build wheels | |
| run: | | |
| export CONAN_CPYTHON_VERSION=${{ matrix.py }} | |
| pip install cython | |
| pip wheel examples/basic --no-build-isolation -C host-profile=../profiles/${{ matrix.profile }} -w examples/basic/dist/ -vv | |
| pip wheel examples/basic-pybind11 --no-build-isolation -C host-profile=../profiles/${{ matrix.profile }} -w examples/basic-pybind11/dist/ -vv | |
| pip wheel examples/basic-meson-pybind11 --no-build-isolation -C host-profile=../profiles/${{ matrix.profile }} -w examples/basic-meson-pybind11/dist/ -vv | |
| pip wheel examples/basic-nanobind --no-build-isolation -C host-profile=../profiles/${{ matrix.profile }} -w examples/basic-nanobind/dist/ -vv | |
| pip wheel examples/external-sources --no-build-isolation -C host-profile=../profiles/${{ matrix.profile }} -w examples/external-sources/dist/ -vv | |
| pip wheel examples/basic-cython --no-build-isolation -C host-profile=../profiles/${{ matrix.profile }} -w examples/basic-cython/dist/ -vv | |
| shell: bash | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.runner }}-py${{ matrix.py }} | |
| path: | | |
| examples/basic/dist/ | |
| examples/basic-pybind11/dist/ | |
| examples/basic-meson-pybind11/dist/ | |
| examples/basic-nanobind/dist/ | |
| examples/external-sources/dist/ | |
| examples/basic-cython/dist/ | |
| docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - run: pip install ".[docs]" | |
| - run: mkdocs build --strict | |
| build-default: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| runner: [ubuntu-latest, macos-14, windows-latest] | |
| runs-on: ${{ matrix.runner }} | |
| env: | |
| CONAN_PY_BUILD_PROFILE_AUTODETECT: "1" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install backend | |
| run: pip install -e . | |
| - name: Build wheels | |
| run: | | |
| pip install cython | |
| pip wheel examples/basic --no-build-isolation -w examples/basic/dist/ -vv | |
| pip wheel examples/basic-pybind11 --no-build-isolation -w examples/basic-pybind11/dist/ -vv | |
| pip wheel examples/basic-meson-pybind11 --no-build-isolation -w examples/basic-meson-pybind11/dist/ -vv | |
| pip wheel examples/basic-nanobind --no-build-isolation -w examples/basic-nanobind/dist/ -vv | |
| pip wheel examples/external-sources --no-build-isolation -w examples/external-sources/dist/ -vv | |
| pip wheel examples/basic-cython --no-build-isolation -w examples/basic-cython/dist/ -vv | |
| shell: bash | |
| - name: Test wheels | |
| run: | | |
| pip install examples/basic/dist/myadder-*.whl examples/basic-pybind11/dist/myadder_pybind11-*.whl examples/basic-meson-pybind11/dist/myadder_meson_pybind11-*.whl examples/basic-nanobind/dist/myadder_nanobind-*.whl examples/external-sources/dist/hello_bindings-*.whl examples/basic-cython/dist/fmt_cython-*.whl | |
| python -c "import myadder; assert myadder.add(2, 3) == 5; assert myadder.add_integers(10, 20) == 30; print('myadder OK')" | |
| python -c "import myadder_pybind11; assert myadder_pybind11.add(2, 3) == 5; assert myadder_pybind11.add_integers(10, 20) == 30; assert myadder_pybind11.greet('World').startswith('Hello'); print('myadder_pybind11 OK')" | |
| python -c "import myadder_meson_pybind11; assert myadder_meson_pybind11.add(2, 3) == 5; print('myadder_meson_pybind11 OK')" | |
| python -c "import extra_utils; assert extra_utils.add(2, 3) == 5" | |
| python -c "import myadder_nanobind; assert myadder_nanobind.add(2, 3) == 5; assert myadder_nanobind.add_integers(10, 20) == 30; assert myadder_nanobind.greet('World').startswith('Hello'); print('myadder_nanobind OK')" | |
| python -c "import hello_bindings; hello_bindings.hello(); print('hello_bindings OK')" | |
| python -c "import myformatter; result = myformatter.sum_of_squares([1.0, 2.0, 3.0, 4.0, 5.0]); assert result == 'sum_of_squares(5 values) = 55.0000', result; print('myformatter OK')" | |
| myadder add 2 3 | grep -q "= 5" | |
| myadder greet World | grep -q "Hello" | |
| shell: bash | |
| - name: Test editable package | |
| run: | | |
| pip uninstall -y myadder_pybind11 | |
| pip install -e examples/basic-pybind11 --no-build-isolation | |
| python -c "import myadder_pybind11; assert myadder_pybind11.add(2, 3) == 5; assert myadder_pybind11.add_integers(10, 20) == 30; assert myadder_pybind11.greet('World').startswith('Hello'); print('myadder_pybind11 OK')" | |
| myadder add 2 3 | grep -q "= 5" | |
| shell: bash | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.runner }} | |
| path: | | |
| examples/basic/dist/ | |
| examples/basic-pybind11/dist/ | |
| examples/basic-meson-pybind11/dist/ | |
| examples/basic-nanobind/dist/ | |
| examples/external-sources/dist/ | |
| examples/basic-cython/dist/ |