Skip to content

Commit

Permalink
#3558 cleanup jobs, skip PyPI deployment on forks
Browse files Browse the repository at this point in the history
  • Loading branch information
agriyakhetarpal committed Nov 27, 2023
1 parent b9edb5c commit 8b2cb45
Showing 1 changed file with 29 additions and 22 deletions.
51 changes: 29 additions & 22 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ on:
env:
# Increase pip debugging output, equivalent to `pip -vv`
CIBW_BUILD_VERBOSITY: 2
# Disable build isolation to allow pre-installing build-time dependencies
# Disable build isolation to allow pre-installing build-time dependencies.
# Note: CIBW_BEFORE_BUILD must be present in all jobs using cibuildwheel.
CIBW_BUILD_FRONTEND: "pip; args: --no-build-isolation"
# Skip PyPy and MUSL builds in any and all jobs
CIBW_SKIP: "pp* *musllinux*"
FORCE_COLOR: 3

jobs:
build_windows_wheels:
name: Build wheels on windows-latest
name: Wheels (windows-latest)
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -62,9 +66,7 @@ jobs:
env:
CIBW_ENVIRONMENT: 'PYBAMM_USE_VCPKG=ON VCPKG_ROOT_DIR=C:\vcpkg VCPKG_DEFAULT_TRIPLET=x64-windows-static-md VCPKG_FEATURE_FLAGS=manifests,registries CMAKE_GENERATOR="Visual Studio 17 2022" CMAKE_GENERATOR_PLATFORM=x64'
CIBW_ARCHS: "AMD64"
CIBW_BEFORE_BUILD: >
python -m pip install --upgrade setuptools wheel
CIBW_TEST_COMMAND: "python -c 'import pybamm; print(pybamm.have_idaklu())' | grep 'True'"
CIBW_BEFORE_BUILD: python -m pip install setuptools wheel

- name: Upload Windows wheels
uses: actions/upload-artifact@v3
Expand All @@ -74,15 +76,18 @@ jobs:
if-no-files-found: error

build_macos_and_linux_wheels:
name: Build wheels on ${{ matrix.os }}
name: Wheels ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
name: Check out PyBaMM repository

- uses: actions/setup-python@v4
name: Set up Python
with:
python-version: 3.8

Expand All @@ -98,28 +103,32 @@ jobs:
python -m pip install cmake wget
python scripts/install_KLU_Sundials.py
- name: Build wheels on ${{ matrix.os }}
- name: Build wheels on Linux
run: pipx run cibuildwheel --output-dir wheelhouse
if: matrix.os == 'ubuntu-latest'
env:
CIBW_ARCHS_LINUX: x86_64
CIBW_BEFORE_ALL_LINUX: >
yum -y install openblas-devel lapack-devel &&
bash scripts/install_sundials.sh 6.0.3 6.5.0
CIBW_BEFORE_BUILD_LINUX: >
python -m pip install cmake casadi setuptools wheel
CIBW_REPAIR_WHEEL_COMMAND_LINUX: >
auditwheel repair -w {dest_dir} {wheel}
CIBW_BEFORE_BUILD_LINUX: python -m pip install cmake casadi setuptools wheel
CIBW_REPAIR_WHEEL_COMMAND_LINUX: auditwheel repair -w {dest_dir} {wheel}
CIBW_TEST_COMMAND: python -c "import pybamm; print(pybamm.have_idaklu())" | grep True

- name: Build wheels on macOS
if: matrix.os == 'macos-latest'
run: pipx run cibuildwheel --output-dir wheelhouse
env:
CIBW_BEFORE_BUILD_MACOS: >
python -m pip install --upgrade cmake casadi setuptools wheel && scripts/fix_suitesparse_rpath_mac.sh
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel}
CIBW_TEST_COMMAND: "python -c 'import pybamm; print(pybamm.have_idaklu())' | grep 'True'"
CIBW_SKIP: "pp* *musllinux*"
python -m pip install --upgrade cmake casadi setuptools wheel &&
scripts/fix_suitesparse_rpath_mac.sh
CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel}
CIBW_TEST_COMMAND: python -c "import pybamm; print(pybamm.have_idaklu())" | grep True

- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
name: macos_linux_wheels
path: ./wheelhouse/*.whl
if-no-files-found: error

Expand All @@ -133,9 +142,6 @@ jobs:
with:
python-version: 3.11

- name: Install dependencies
run: pip install --upgrade pip setuptools wheel

- name: Build SDist
run: pipx run build --sdist

Expand All @@ -147,7 +153,8 @@ jobs:
if-no-files-found: error

publish_pypi:
if: github.event_name != 'schedule'
# This job is only of value to PyBaMM and would always be skipped in forks
if: github.event_name != 'schedule' && github.repository == 'pybamm-team/PyBaMM'
name: Upload package to PyPI
needs: [build_macos_and_linux_wheels, build_windows_wheels, build_sdist]
runs-on: ubuntu-latest
Expand All @@ -158,7 +165,7 @@ jobs:
- name: Move all package files to files/
run: |
mkdir files
mv windows_wheels/* wheels/* sdist/* files/
mv windows_wheels/* macos_linux_wheels/* sdist/* files/
- name: Publish on PyPI
if: github.event.inputs.target == 'pypi' || github.event_name == 'release'
Expand Down

0 comments on commit 8b2cb45

Please sign in to comment.