python: Enable logging in shared #613
Workflow file for this run
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: Build Python wheels | |
| on: | |
| push: | |
| branches: [main] | |
| tags: 'lakers-python-v*' | |
| workflow_dispatch: | |
| pull_request: | |
| jobs: | |
| build-python-wheels: | |
| name: Build wheels on ${{ matrix.os }} with Python ${{ matrix.python-version }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ | |
| ubuntu-latest, | |
| ubuntu-24.04-arm, | |
| windows-latest, | |
| macos-latest, | |
| ] # see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners | |
| python-version: [ | |
| 'pypy3.11', | |
| '3.10', | |
| '3.11', | |
| '3.12', | |
| '3.13', | |
| '3.14', | |
| ] # see https://devguide.python.org/versions/ | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| # practical while new releases are coming out, and doesn't hurt to keep around. | |
| allow-prereleases: true | |
| architecture: ${{ (startsWith(matrix.os, 'macos') || endsWith(matrix.os, '-arm')) && 'arm64' || 'x64' }} | |
| - name: Install maturin | |
| run: python -m pip install maturin | |
| - name: Build source distribution # do this only once | |
| run: | | |
| cd lakers-python | |
| ln -s ../examples ./examples # make sure examples are available in sdist (because examples/coap is in default-members) | |
| maturin build --sdist --out wheelhouse | |
| if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' | |
| # By building from sdist once we ensure that all components needed (see | |
| # the dev-dependencies of lakers-python for an example) are available not | |
| # just in the environment but also inside the sdist, and Cargo can run | |
| # through. | |
| - name: Build wheels from sdist | |
| run: | | |
| mkdir unpacked-source | |
| cd unpacked-source | |
| tar xf ../lakers-python/wheelhouse/lakers_python-*.tar.gz | |
| cd lakers_python-* | |
| maturin build --release --out ../../lakers-python/wheelhouse | |
| if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' | |
| # Building from tree most of the time because otherwise the sdist would | |
| # need to be synchronized across all the jobs. | |
| - name: Build wheels from tree | |
| run: | | |
| cd lakers-python | |
| maturin build --release --out wheelhouse | |
| if: matrix.os != 'ubuntu-latest' || matrix.python-version != '3.11' | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheel-${{ matrix.os }}-python-${{ matrix.python-version }} | |
| path: ./lakers-python/wheelhouse/lakers_python* | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: [build-python-wheels] | |
| if: >- | |
| github.event_name == 'push' && | |
| startsWith(github.event.ref, 'refs/tags') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: set up python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - run: pip install -U twine | |
| - name: get wheelhouse artifacts | |
| uses: actions/download-artifact@v4.1.7 | |
| with: | |
| path: wheelhouse | |
| - run: ls -lah ./wheelhouse/*/lakers_python* | |
| - run: twine check ./wheelhouse/*/lakers_python* | |
| - name: upload to pypi | |
| run: twine upload ./wheelhouse/*/lakers_python* | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_UPLOAD_TOKEN }} |