Skip to content

Commit

Permalink
Try to build wheels into consoidated folder-s
Browse files Browse the repository at this point in the history
  • Loading branch information
adam2392 committed Jun 24, 2024
1 parent 720d7e6 commit 6d9bb57
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 131 deletions.
34 changes: 31 additions & 3 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,14 @@ jobs:
# - [macos-12, macosx_*, arm64]
- [windows-2019, win, AMD64]

python: [["cp39", "3.9"], ["cp310", "3.10"], ["cp311", "3.11"], ["cp312", "3.12"]]
# python[0] is used to specify the python versions made by cibuildwheel
python:
[
["cp39", "3.9"],
["cp310", "3.10"],
["cp311", "3.11"],
["cp312", "3.12"],
]

env:
IS_32_BIT: ${{ matrix.os[2] == 'x86' }}
Expand Down Expand Up @@ -99,8 +105,14 @@ jobs:
# Ensure that a wheel builder finishes even if another fails
fail-fast: false
matrix:
python: [["cp39", "3.9"], ["cp310", "3.10"], ["cp311", "3.11"], ["cp312", "3.12"]]
# python[0] is used to specify the python versions made by cibuildwheel
python:
[
["cp39", "3.9"],
["cp310", "3.10"],
["cp311", "3.11"],
["cp312", "3.12"],
]

steps:
- name: Checkout code
Expand Down Expand Up @@ -141,7 +153,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10" # update once build dependencies are available
python-version: "3.10"

- name: Build source distribution
run: |
Expand All @@ -159,3 +171,19 @@ jobs:
with:
path: dist
name: ${{ matrix.python[0] }}-${{ matrix.os[1] }}

merge-wheels:
name: Merge all wheels into one directory
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: all
- name: Merge files
run: |
mkdir dist
mv all/*/dist/* ./dist
- uses: actions/upload-artifact@v4
with:
path: dist
name: dist
149 changes: 21 additions & 128 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,152 +10,45 @@ on:
push:
branches:
- main
workflow_run:
workflows: [Build Wheels]
branches: [main]
pull_request:
branches:
- main

permissions:
contents: read

env:
INSTALLDIR: "build-install"
CCACHE_DIR: "${{ github.workspace }}/.ccache"

jobs:
# release is ran when a release is made on Github
# Build the source distribution under Linux
build_sdist:
name: Build source distribution
check_wheels:
runs-on: ubuntu-latest

steps:
- name: Checkout scikit-tree
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10" # update once build dependencies are available

- name: Build source distribution
run: |
pip install spin build
spin setup-submodule
pip install .[build]
python -m build
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist

build_wheels:
name: Build wheels on ${{ matrix.os[1] }} - ${{ matrix.os[2] }} with Python ${{ matrix.python[0] }}
runs-on: ${{ matrix.os[0] }}

strategy:
# Ensure that a wheel builder finishes even if another fails
fail-fast: false
matrix:
os: # see scipy wheels.yml GH actions
- [ubuntu-22.04, manylinux, x86_64]
- [macos-12, macosx, x86_64]
# - [macos-12, macosx_*, arm64]
- [windows-2019, win, AMD64]

python: [["cp39", "3.9"], ["cp310", "3.10"], ["cp311", "3.11"], ["cp312", "3.12"]]
# python[0] is used to specify the python versions made by cibuildwheel

env:
IS_32_BIT: ${{ matrix.os[2] == 'x86' }}

steps:
- name: Checkout scikit-tree
uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Setup submodule
- name: Get run ID of "Test" workflow
id: get-run-id
run: |
python -m pip install --upgrade pip spin
python -m spin setup-submodule
- name: win_amd64 - install rtools
run: |
choco install rtools -y --no-progress --force --version=4.0.0.20220206
echo "c:\rtools40\ucrt64\bin;" >> $env:GITHUB_PATH
if: ${{ runner.os == 'Windows' && env.IS_32_BIT == 'false' }}

- name: Build wheels
uses: pypa/[email protected]
# Build all wheels here, apart from macosx_arm64, linux_aarch64
# cibuildwheel is currently unable to pass configuration flags to
# CIBW_BUILD_FRONTEND https://github.com/pypa/cibuildwheel/issues/1227
# (pip/build). Cross compilation with meson requires an initial
# configuration step to create a build directory. The subsequent wheel
# build then needs to use that directory. This can be done with pip
# using a command like:
# pip wheel --config-settings builddir=build .
# if: >-
# ( ! contains(matrix.os[2], 'arm64' ) )
OTHER_REPO="${{ github.repository }}"
WF_NAME="Build Wheels"
RUN_ID=`gh run --repo ${OTHER_REPO} list --workflow ${WF_NAME} --json databaseId --jq .[0].databaseId`
echo "Detected latest run id of ${RUN_ID} for workflow ${WF_NAME}"
echo "run-id=${RUN_ID}" >> "$GITHUB_OUTPUT"
env:
CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.os[1] }}*
CIBW_ARCHS: ${{ matrix.os[2] }}
CIBW_ENVIRONMENT_PASS_LINUX: RUNNER_OS
GH_TOKEN: ${{ github.token }}

# - name: Move wheels to dist
# run: |
# mkdir -p dist
# mv ./wheelhouse/* dist/

- uses: actions/upload-artifact@v4
- name: Download artifact from "Build Wheels" workflow
uses: actions/download-artifact@v4
with:
name: dist
path: dist

build-wheels-m1:
name: Build wheels on Arm M1 with Python ${{ matrix.python[0] }}
runs-on: macos-latest

strategy:
# Ensure that a wheel builder finishes even if another fails
fail-fast: false
matrix:
python: [["cp39", "3.9"], ["cp310", "3.10"], ["cp311", "3.11"], ["cp312", "3.12"]]
# python[0] is used to specify the python versions made by cibuildwheel

steps:
- name: Checkout code
uses: actions/checkout@v4
name: dist # Match name used in test.yml upload artifact step
github-token: ${{ github.token }}
repository: ${{ github.repository }}
run-id: ${{ steps.get-run-id.outputs.run-id }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10" # Replace with the desired Python version

- name: Install cibuildwheel dependencies
run: |
pip install cibuildwheel
pip install spin
spin setup-submodule
pip install .[build]
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BUILD: ${{ matrix.python[0] }}-macosx_arm64
CIBW_ARCHS_MACOS: arm64

- uses: actions/upload-artifact@v4
with:
name: dist
path: dist
- name: Show downloaded files
run: ls -la

# PyPI on release
pypi:
needs: [build_sdist, build_wheels, build-wheels-m1]
needs: [check_wheels]
runs-on: ubuntu-latest
if: github.event_name == 'release'
permissions:
Expand Down

0 comments on commit 6d9bb57

Please sign in to comment.