Skip to content

cibuildwheel

cibuildwheel #48

Workflow file for this run

name: cibuildwheel
on:
workflow_dispatch:
inputs:
publish:
description: 'Publish wheels to PyPI: (testpypi/pypi/none)'
required: false
type: choice
options:
- testpypi
- pypi
- none
default: none
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-12, macos-14]
steps:
- uses: actions/checkout@v4
- name: Set up optimizers on Linux
uses: ./.github/actions/setup_optimizers_linux
if: runner.os == 'Linux'
with:
GUROBI_WLS: ${{ secrets.GUROBI_WLS }}
COPT_CLIENT_INI: ${{ secrets.COPT_CLIENT_INI }}
MOSEK_LICENSE: ${{ secrets.MOSEK_LICENSE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CHECK_LICENSE: false
- name: Set up optimizers on Windows
uses: ./.github/actions/setup_optimizers_windows
if: runner.os == 'Windows'
with:
GUROBI_WLS: ${{ secrets.GUROBI_WLS }}
COPT_CLIENT_INI: ${{ secrets.COPT_CLIENT_INI }}
MOSEK_LICENSE: ${{ secrets.MOSEK_LICENSE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CHECK_LICENSE: false
- name: Set up optimizers on macOS
uses: ./.github/actions/setup_optimizers_macos
if: runner.os == 'macOS'
with:
GUROBI_WLS: ${{ secrets.GUROBI_WLS }}
COPT_CLIENT_INI: ${{ secrets.COPT_CLIENT_INI }}
MOSEK_LICENSE: ${{ secrets.MOSEK_LICENSE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CHECK_LICENSE: false
ARCH: ${{ runner.arch }}
- name: Build wheels
uses: pypa/[email protected]
env:
# Select wheels
CIBW_BUILD: "*-manylinux_x86_64 *-win_amd64 *-macosx_x86_64 *-macosx_arm64"
CIBW_SKIP: "cp36-* cp37-* pp* cp38-macosx_arm64"
CIBW_ARCHS: "native"
# use manylinux2014
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
# setup some environment variables for GUROBI_HOME, MOSEK_HOME, etc.
CIBW_ENVIRONMENT_PASS_LINUX: GUROBI_HOME COPT_HOME MOSEK_10_1_BINDIR HiGHS_HOME
# append /host in front of these environment variables because we are in docker
CIBW_ENVIRONMENT_LINUX: >
GUROBI_HOME=/host$GUROBI_HOME
COPT_HOME=/host$COPT_HOME
MOSEK_10_1_BINDIR=/host$MOSEK_10_1_BINDIR
HiGHS_HOME=/host$HiGHS_HOME
CIBW_BEFORE_ALL_LINUX: >
echo "GUROBI_HOME=${GUROBI_HOME}" &&
ls -l $GUROBI_HOME &&
echo "COPT_HOME=${COPT_HOME}" &&
ls -l $COPT_HOME &&
echo "MOSEK_10_1_BINDIR=${MOSEK_10_1_BINDIR}" &&
ls -l $MOSEK_10_1_BINDIR &&
echo "HiGHS_HOME=${HiGHS_HOME}" &&
ls -l $HiGHS_HOME
CIBW_ENVIRONMENT_MACOS: >
MACOSX_DEPLOYMENT_TARGET=10.14
CIBW_TEST_COMMAND: "python -c \"import pyoptinterface as poi; print(dir(poi))\""
with:
package-dir: .
output-dir: wheelhouse
config-file: "{package}/pyproject.toml"
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ runner.os }}-${{ runner.arch }}
path: ./wheelhouse/*.whl
publish-to-testpypi:
name: Publish Python wheels to TestPyPI
needs:
- build_wheels
runs-on: ubuntu-latest
if: github.event.inputs.publish == 'testpypi'
environment:
name: testpypi
url: https://test.pypi.org/p/pyoptinterface
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
pattern: cibw-wheels-*
merge-multiple: true
path: dist/
- name: List all the dists
run: ls -l dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
publish-to-pypi:
name: Publish Python wheels to PyPI
needs:
- build_wheels
runs-on: ubuntu-latest
if: github.event.inputs.publish == 'pypi'
environment:
name: pypi
url: https://pypi.org/project/pyoptinterface/
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
pattern: cibw-wheels-*
merge-multiple: true
path: dist/
- name: List all the dists
run: ls -l dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://upload.pypi.org/legacy/