Build version-agnostic wheels (#2343)

This commit is contained in:
Cuong Duong 2023-01-20 10:33:43 +11:00 committed by GitHub
parent 2f84620a28
commit 583f81e428
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 11 deletions

View file

@ -11,28 +11,37 @@ env:
jobs:
make-wheels:
name: Make ${{ matrix.os }} ${{ matrix.cibw_arch }} ${{ matrix.py_version }} wheels
name: Make ${{ matrix.os }} ${{ matrix.cibw_arch }} wheels
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["macos-latest", "ubuntu-latest", "windows-latest"]
cibw_arch: ["native", "aarch64"]
py_version: ["cp37-*", "cp38-*", "cp39-*", "cp310-*"]
exclude:
- os: macos-latest
cibw_arch: "aarch64"
- os: windows-latest
cibw_arch: "aarch64"
cibw_arch: ["native"]
# Build one wheel (ABI = none) using first build spec, then test on all python versions.
cibw_build: ["cp37-* cp38-* cp39-* cp310-* cp311-*"]
include:
- os: ubuntu-latest
cibw_arch: aarch64
# Each test takes 30 mins, which is too long to run sequentially, so we test once only.
cibw_build: "cp37-*"
fail-fast: false
steps:
- name: "Set 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
- name: "Checkout repo"
uses: actions/checkout@v3
- name: "Restore RTools40"
if: startsWith(runner.os, 'Windows')
id: cache-rtools
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: C:/rtools40
key: ${{ runner.os }}-${{ env.OS_VERSION }}-rtools-v1
@ -44,14 +53,14 @@ jobs:
platforms: arm64
- name: "Build wheels"
uses: pypa/cibuildwheel@v2.6.0
uses: pypa/cibuildwheel@v2.11.4
with:
package-dir: python
env:
CIBW_ENVIRONMENT: >
STAN_BACKEND="${{ env.STAN_BACKEND }}"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_BUILD: ${{ matrix.py_version }}
CIBW_BUILD: ${{ matrix.cibw_build }}
CIBW_SKIP: "*musllinux*"
CIBW_ARCHS: ${{ matrix.cibw_arch }}
CIBW_BUILD_FRONTEND: build

View file

@ -13,6 +13,7 @@ from setuptools import find_packages, setup, Extension
from setuptools.command.build_ext import build_ext
from setuptools.command.build_py import build_py
from setuptools.command.editable_wheel import editable_wheel
from wheel.bdist_wheel import bdist_wheel
MODEL_DIR = "stan"
@ -164,6 +165,16 @@ class EditableWheel(editable_wheel):
editable_wheel.run(self)
class BDistWheelABINone(bdist_wheel):
def finalize_options(self):
bdist_wheel.finalize_options(self)
self.root_is_pure = False
def get_tag(self):
_, _, plat = bdist_wheel.get_tag(self)
return "py3", "none", plat
about = {}
here = Path(__file__).parent.resolve()
with open(here / "prophet" / "__version__.py", "r") as f:
@ -179,6 +190,7 @@ setup(
"build_ext": BuildExtCommand,
"build_py": BuildPyCommand,
"editable_wheel": EditableWheel,
"bdist_wheel": BDistWheelABINone,
},
test_suite="prophet.tests",
)