From 78ee6253f4ce4c311d6309ebf02046f7a758d48a Mon Sep 17 00:00:00 2001 From: Geovane Fedrecheski Date: Tue, 13 Feb 2024 10:44:23 +0100 Subject: [PATCH 1/5] ci: build wheels for many python versions --- .github/workflows/build-and-test.yml | 8 ++-- .github/workflows/python-wheels.yml | 61 ++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/python-wheels.yml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 28e2ce69..4ddc356a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -1,10 +1,10 @@ name: Build and test on: - push: - branches: [main] - tags: 'v*' - pull_request: + # push: + # branches: [main] + # tags: 'v*' + # pull_request: workflow_dispatch: env: diff --git a/.github/workflows/python-wheels.yml b/.github/workflows/python-wheels.yml new file mode 100644 index 00000000..429bf421 --- /dev/null +++ b/.github/workflows/python-wheels.yml @@ -0,0 +1,61 @@ +name: Build Python wheels + +on: + push: + branches: [main] + tags: 'v*' + pull_request: + workflow_dispatch: + +jobs: + build-python-wheels: + name: Build wheels on ${{ matrix.os }} with Python ${{ matrix.python-version }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] #, windows-latest, macos-13, macos-14] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + + steps: + - uses: actions/checkout@v4 + + - name: Set up rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + + - run: rustup target add aarch64-apple-darwin + if: matrix.os == 'macos-13' || matrix.os == 'macos-14' + + - run: | + rustup toolchain install stable-i686-pc-windows-msvc + rustup target add i686-pc-windows-msvc + if: matrix.os == 'windows' + + - name: Check Rust versions + run: | + rustc --version + which rustc + cargo --version + which cargo + rustup --version + which rustup + + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + architecture: x64 + + - name: Install maturin + run: python -m pip install maturin + + - name: Build wheels + run: | + cd lakers-python + maturin build --out wheelhouse + + - uses: actions/upload-artifact@v4 + with: + name: wheel-${{ matrix.os }}-python-${{ matrix.python-version }} + path: ./lakers-python/wheelhouse/*.whl From 54b602668d5355cf7bc4a2b141e38e9c79efc47e Mon Sep 17 00:00:00 2001 From: Geovane Fedrecheski Date: Wed, 14 Feb 2024 11:04:58 +0100 Subject: [PATCH 2/5] ci: build wheels in multiple OSes --- .github/workflows/python-wheels.yml | 32 +++++++++++------------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/.github/workflows/python-wheels.yml b/.github/workflows/python-wheels.yml index 429bf421..a00cb102 100644 --- a/.github/workflows/python-wheels.yml +++ b/.github/workflows/python-wheels.yml @@ -12,9 +12,18 @@ jobs: name: Build wheels on ${{ matrix.os }} with Python ${{ matrix.python-version }} runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: - os: [ubuntu-latest] #, windows-latest, macos-13, macos-14] - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + os: [ + ubuntu-latest, + windows-latest, + macos-13, # latest non-beta version + ] # see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners + python-version: [ + '3.10', + '3.11', + '3.12' + ] # see https://devguide.python.org/versions/ steps: - uses: actions/checkout@v4 @@ -24,25 +33,8 @@ jobs: with: toolchain: stable - - run: rustup target add aarch64-apple-darwin - if: matrix.os == 'macos-13' || matrix.os == 'macos-14' - - - run: | - rustup toolchain install stable-i686-pc-windows-msvc - rustup target add i686-pc-windows-msvc - if: matrix.os == 'windows' - - - name: Check Rust versions - run: | - rustc --version - which rustc - cargo --version - which cargo - rustup --version - which rustup - - name: Set up Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} architecture: x64 From cc42156198c8eb953e080033eecac66a0e87ebf1 Mon Sep 17 00:00:00 2001 From: Geovane Fedrecheski Date: Wed, 14 Feb 2024 12:00:28 +0100 Subject: [PATCH 3/5] ci: publish python wheels on release --- .github/workflows/python-wheels.yml | 43 +++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python-wheels.yml b/.github/workflows/python-wheels.yml index a00cb102..7debd483 100644 --- a/.github/workflows/python-wheels.yml +++ b/.github/workflows/python-wheels.yml @@ -22,7 +22,7 @@ jobs: python-version: [ '3.10', '3.11', - '3.12' + '3.12', ] # see https://devguide.python.org/versions/ steps: @@ -42,12 +42,49 @@ jobs: - name: Install maturin run: python -m pip install maturin + - name: Build source distribution # do this only once + run: | + cd lakers-python + maturin build --sdist --out wheelhouse + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' + - name: Build wheels run: | cd lakers-python - maturin build --out wheelhouse + maturin build --release --out wheelhouse - uses: actions/upload-artifact@v4 with: name: wheel-${{ matrix.os }}-python-${{ matrix.python-version }} - path: ./lakers-python/wheelhouse/*.whl + 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 + 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 }} From 533dad80602702fef365d3ec38e7a7b0a4efecc8 Mon Sep 17 00:00:00 2001 From: Geovane Fedrecheski Date: Wed, 14 Feb 2024 14:33:06 +0100 Subject: [PATCH 4/5] ci: do not upload python artifacts twice --- .github/workflows/build-and-test.yml | 32 ++++++++++------------------ 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 4ddc356a..a2074ab5 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -1,10 +1,10 @@ name: Build and test on: - # push: - # branches: [main] - # tags: 'v*' - # pull_request: + push: + branches: [main] + tags: 'v*' + pull_request: workflow_dispatch: env: @@ -132,7 +132,7 @@ jobs: path: ./target/lakers-c-*.zip - build-lakers-python: + test-lakers-python: needs: check-style runs-on: ubuntu-latest @@ -143,22 +143,17 @@ jobs: - name: Checkout repo uses: actions/checkout@v3 - - name: Build Python package + - name: set up python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: Test Python package run: | cd lakers-python - python3 -m venv .venv - source .venv/bin/activate pip install --upgrade pip pip install -U pip maturin pytest - pip freeze maturin develop && pytest - maturin build - - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: lakers-python - path: ./target/wheels/*.whl run-example-on-qemu: @@ -247,11 +242,6 @@ jobs: with: name: lakers-c path: ./release-artifacts - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: lakers-python - path: ./release-artifacts - name: Release uses: ncipollo/release-action@v1 with: From 0f85f82b725b8e7d99b97a0212df61af2fede314 Mon Sep 17 00:00:00 2001 From: Geovane Fedrecheski Date: Wed, 14 Feb 2024 14:35:05 +0100 Subject: [PATCH 5/5] ci: only build all wheels manually and upon v* tags --- .github/workflows/build-and-test.yml | 5 ++++- .github/workflows/python-wheels.yml | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index a2074ab5..198ae486 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -151,8 +151,11 @@ jobs: - name: Test Python package run: | cd lakers-python + python3 -m venv .venv + source .venv/bin/activate pip install --upgrade pip - pip install -U pip maturin pytest + pip install -U maturin pytest + pip freeze maturin develop && pytest diff --git a/.github/workflows/python-wheels.yml b/.github/workflows/python-wheels.yml index 7debd483..25ef6347 100644 --- a/.github/workflows/python-wheels.yml +++ b/.github/workflows/python-wheels.yml @@ -4,7 +4,6 @@ on: push: branches: [main] tags: 'v*' - pull_request: workflow_dispatch: jobs: