Build wheels with native cibuildwheelaction (#2190)

This commit is contained in:
Anatoli Babenia 2022-06-24 14:45:23 +03:00 committed by GitHub
parent 84132a29eb
commit 94fbe79f44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,138 +10,34 @@ env:
STAN_BACKEND: "CMDSTANPY"
jobs:
make-wheel-windows:
name: ${{ matrix.python-version }}-${{ matrix.architecture }}-${{ matrix.os }}
make-wheels:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["windows-latest"]
python-version: [3.8]
architecture: ["x64"]
os: ["macos-latest", "ubuntu-latest", "windows-latest"]
fail-fast: false
steps:
- name: "Setup environment variables (Windows)"
if: startsWith(runner.os, 'Windows')
shell: pwsh
run: |
(Get-ItemProperty "HKLM:System\CurrentControlSet\Control\FileSystem").LongPathsEnabled
$os_version = (Get-CimInstance Win32_OperatingSystem).version
Echo "OS_VERSION=$os_version" >> $env:GITHUB_ENV
Echo "PIP_DEFAULT_CACHE=$HOME/pip/cache" >> $env:GITHUB_ENV
Echo "DEFAULT_HOME=$HOME" >> $env:GITHUB_ENV
- name: "Checkout repo"
uses: actions/checkout@v2
- name: "Set up Python"
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
- name: "Restore pip cache"
id: cache-pip
uses: actions/cache@v2
with:
path: ${{ env.PIP_DEFAULT_CACHE }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/python/requirements.txt') }}-v1
restore-keys: |
${{ runner.os }}-pip-
- name: "Install pip"
shell: pwsh
run: |
python -m pip install --upgrade pip
python -m pip install cibuildwheel build delvewheel
uses: actions/checkout@v3
- name: "Restore RTools40"
if: startsWith(runner.os, 'Windows')
id: cache-rtools
uses: actions/cache@v2
with:
path: C:/rtools40
key: ${{ runner.os }}-${{ env.OS_VERSION }}-rtools-v1
- name: "Build wheel"
run: |
cd python && python -m cibuildwheel --output-dir wheelhouse
- name: "Build wheels"
uses: pypa/cibuildwheel@v2.6.0
with:
package-dir: python
env:
CIBW_ENVIRONMENT: >
STAN_BACKEND="${{ env.STAN_BACKEND }}"
PIP_CACHE_DIR="${{ env.PIP_DEFAULT_CACHE }}"
CIBW_BUILD: cp37-* cp38-* cp39-* cp310-*
CIBW_ARCHS: native
CIBW_BUILD_FRONTEND: build
# CIBW_REPAIR_WHEEL_COMMAND: delvewheel repair -w {dest_dir} {wheel}
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: pytest --pyargs prophet
- name: "Upload wheel as artifact"
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.os }}-wheel
path: "./**/*.whl"
make-wheels-macos-linux:
name: ${{ matrix.python-version }}-${{ matrix.architecture }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["macos-latest", "ubuntu-latest"]
python-version: [3.8]
architecture: ["x64"]
fail-fast: false
steps:
- name: "Get OS version (Linux)"
if: startsWith(runner.os, 'Linux')
run: |
echo "PIP_DEFAULT_CACHE=$HOME/.cache/pip" >> $GITHUB_ENV
echo "DEFAULT_HOME=$HOME" >> $GITHUB_ENV
- name: "Get OS version (macOS)"
if: startsWith(runner.os, 'macOS')
run: |
echo "PIP_DEFAULT_CACHE=$HOME/Library/Caches/pip" >> $GITHUB_ENV
echo "DEFAULT_HOME=$HOME" >> $GITHUB_ENV
- name: "Checkout repo"
uses: actions/checkout@v2
- name: "Set up Python"
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
- name: "Restore pip cache"
id: cache-pip
uses: actions/cache@v2
with:
path: ${{ env.PIP_DEFAULT_CACHE }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/python/requirements.txt') }}-v1
restore-keys: |
${{ runner.os }}-pip-
- name: "Install pip"
run: |
python -m pip install --upgrade pip
python -m pip install cibuildwheel build
- name: "Build wheel"
run: |
cd python && python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ENVIRONMENT: >
STAN_BACKEND="${{ env.STAN_BACKEND }}"
# Linux builds run in a Docker container, need to point the cache to the host machine.
CIBW_ENVIRONMENT_LINUX: >
STAN_BACKEND="${{ env.STAN_BACKEND }}"
HOME="/host/${{ env.DEFAULT_HOME }}"
PIP_CACHE_DIR="/host/${{ env.PIP_DEFAULT_CACHE }}"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_BEFORE_ALL_LINUX: chmod -R a+rwx /host/${{ env.PIP_DEFAULT_CACHE }}
CIBW_BUILD: cp37-* cp38-* cp39-* cp310-*
CIBW_SKIP: "*musllinux*"
CIBW_ARCHS: native