From 04987bca4b3c09fa958d4855c39ee110a4071e64 Mon Sep 17 00:00:00 2001 From: Nickolai Belakovski Date: Fri, 12 Jan 2024 12:23:17 -0800 Subject: [PATCH] adding cibuildwheel --- .github/workflows/build_python.yml | 85 ++++-------------------------- pyproject.toml | 4 ++ 2 files changed, 14 insertions(+), 75 deletions(-) diff --git a/.github/workflows/build_python.yml b/.github/workflows/build_python.yml index 5bc2ef4e90..cf1d78caf9 100644 --- a/.github/workflows/build_python.yml +++ b/.github/workflows/build_python.yml @@ -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 - - 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 diff --git a/pyproject.toml b/pyproject.toml index f3e8acb570..91cead4440 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"] @@ -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"