Skip to content

Commit

Permalink
adding cibuildwheel
Browse files Browse the repository at this point in the history
  • Loading branch information
nbelakovski committed Jan 12, 2024
1 parent 1c085c7 commit 04987bc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 75 deletions.
85 changes: 10 additions & 75 deletions .github/workflows/build_python.yml
Original file line number Diff line number Diff line change
@@ -1,86 +1,21 @@
name: CMake build
name: Build python wheels

on:
push:
pull_request:
schedule:
- cron: '0 0 * * 1' # 0h mondays
workflow_dispatch:
inputs:
git-ref:
description: Git Ref (Optional)
required: false

# Show the git ref in the workflow name if it is invoked manually.
run-name: ${{ github.event_name == 'workflow_dispatch' && format('Manual run {0} ', inputs.git-ref) || '' }}


permissions:
contents: read
on: [push, pull_request]

jobs:

build-python:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
continue-on-error: true
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-2019]
# env:
# BUILD_PYTHON_CI: 1 # Or maybe just a cmake option BUILD_PYTHON? Defaulted to false? And maybe we can set shared libs to false for this build?
os: [ubuntu-20.04, windows-2019, macos-11]

steps:
- uses: actions/checkout@v4

- name: Clone Repository (Latest)
uses: actions/checkout@v4
if: github.event.inputs.git-ref == ''
with:
ssh-key: ${{ secrets.SSH_PRIVATE_KEY_ACT }} # This forces checkout to use SSH, not HTTPS
submodules: recursive
- name: Clone Repository (Custom Ref)
uses: actions/checkout@v4
if: github.event.inputs.git-ref != ''
with:
ref: ${{ github.event.inputs.git-ref }}
ssh-key: ${{ secrets.SSH_PRIVATE_KEY_ACT }} # This forces checkout to use SSH, not HTTPS
submodules: recursive
- name: Build wheels
uses: pypa/cibuildwheel@v2.16.2

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

cibuildwheel is not a recognized word. (unrecognized-spelling)

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

pypa is not a recognized word. (unrecognized-spelling)

- name: Set up Python
uses: actions/setup-python@v5
- uses: actions/upload-artifact@v3
with:
python-version: '3.11'

- run: pip install numpy pytest
- run: python -c "import sys; print('PYTHON_EXECUTABLE=' + sys.executable)" >> $GITHUB_ENV
shell: bash

- name: Install Ninja / Ubuntu
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt update && sudo apt install ninja-build
- name: Install Ninja / MacOS
if: ${{ matrix.os == 'macos-latest' }}
run: brew install ninja
- name: Install Ninja / Windows
if: ${{ matrix.os == 'windows-2022' }}
run: choco install ninja

- name: Win_amd64 - install rtools
if: ${{ matrix.os == 'windows-2022' }}
run: |
# mingw-w64
choco install rtools -y --no-progress --force --version=4.0.0.20220206
echo "c:\rtools40\ucrt64\bin;" >> $env:GITHUB_PATH
# TODO: I need to move the mingw folder so that it doesn't pick up the wrong gcc, yes?

- name: Build
run: |
cmake --version
cmake -G Ninja -DPython_EXECUTABLE=$PYTHON_EXECUTABLE -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=. -LAH .
cmake --build . --target prima_pybind
cmake --build . --target tests
ctest --output-on-failure -V -R python-tests
shell: bash

# This is a work in progress, more to come.
path: ./wheelhouse/*.whl

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

whl is not a recognized word. (unrecognized-spelling)
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ build-backend = "scikit_build_core.build"
name = "prima"
dependencies = ["numpy"]
dynamic = ["version"]
requires-python = ">= 3.7" # Driving factor is availavility of scikit-build-core

[tool.scikit-build]
cmake.targets = ["_prima"]
Expand All @@ -15,3 +16,6 @@ install.components = ["Prima_Python_C_Extension"]

[tool.setuptools_scm] # Section required
version_file = "_version.txt"

[tool.cibuildwheel]
test-command = "pytest -s {project}/python/tests"

0 comments on commit 04987bc

Please sign in to comment.