Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i3558 improve wheel repair + add minimal IDAKLU test for built wheels #3569

Merged
merged 28 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
71e6245
#3558 Add CasADi to RPATH when linking `idaklu` target
agriyakhetarpal Nov 27, 2023
1d08d0f
#3558 Import `casadi` using `importlib` instead
agriyakhetarpal Nov 27, 2023
dfc0901
#3558 add minimal test command and remove LD_LIBRARY_PATH override
agriyakhetarpal Nov 27, 2023
d0be7ba
#3558 remove script for RPATH adjustment
agriyakhetarpal Nov 27, 2023
b9edb5c
#3558 enable comment to disable build isolation
agriyakhetarpal Nov 27, 2023
8b2cb45
#3558 cleanup jobs, skip PyPI deployment on forks
agriyakhetarpal Nov 27, 2023
4a0bbd3
#3558 cover Windows wheel job with tests
agriyakhetarpal Nov 27, 2023
d150be3
Use `next(iter())` to evaluate `casadi` search paths
agriyakhetarpal Nov 30, 2023
b260113
Merge branch 'develop' into i3558-repair-wheel
agriyakhetarpal Nov 30, 2023
5df9f8a
#3558 try to initialise IDAKLU solver instead of just importing it
agriyakhetarpal Dec 1, 2023
52697f2
#3558 #3100 keep equal `casadi` dependency versions
agriyakhetarpal Dec 1, 2023
8608682
#3558 #3100 Don't use a default path to search for alternative `casad…
agriyakhetarpal Dec 1, 2023
d900a81
#3558 build SuiteSparse with INSTALL_RPATH
agriyakhetarpal Dec 14, 2023
6a9743d
#3558 Remove some unused CMake arguments
agriyakhetarpal Dec 14, 2023
29941ce
#3558 Remove SuiteSparse macOS RPATH fixer script
agriyakhetarpal Dec 14, 2023
8e59c1b
#3361 #3558 Improve caching and remove `examples/`
agriyakhetarpal Dec 14, 2023
ab6b6bd
Merge branch 'develop' into i3558-repair-wheel
agriyakhetarpal Dec 14, 2023
7f1f74f
#3558 Remove `scripts/fix_suitesparse_rpath_mac.sh`
agriyakhetarpal Dec 14, 2023
ade8e7d
#3558 Set BUILD AND INSTALL RPATHs correctly
agriyakhetarpal Dec 14, 2023
e4f4af3
Merge branch 'develop' into i3558-repair-wheel
agriyakhetarpal Dec 21, 2023
a04fce6
#3646 fix parallel level, set environment variable
agriyakhetarpal Dec 21, 2023
3dc8c8c
#3646 set parallel variable for `build_ext` (IDAKLU)
agriyakhetarpal Dec 21, 2023
139e34d
#3646 set parallel jobs for `pybamm_install_odes`
agriyakhetarpal Dec 22, 2023
971ef8a
#3646 set parallel jobs for `install_sundials.sh`
agriyakhetarpal Dec 22, 2023
79fa0b8
Merge branch 'develop' into i3558-repair-wheel
agriyakhetarpal Jan 3, 2024
0218ac4
style: pre-commit fixes
pre-commit-ci[bot] Jan 3, 2024
9017c21
#3646 set CMake parallelism for Windows wheels
agriyakhetarpal Jan 6, 2024
632bcec
#3646 Use `os.cpu_count` rather than processor affinity
agriyakhetarpal Jan 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 39 additions & 24 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,20 @@ on:
required: false
default: false

# Set options available for all jobs that use cibuildwheel
env:
# Increase pip debugging output, equivalent to `pip -vv`
CIBW_BUILD_VERBOSITY: 2
# 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"
agriyakhetarpal marked this conversation as resolved.
Show resolved Hide resolved
# Skip PyPy and MUSL builds in any and all jobs
CIBW_SKIP: "pp* *musllinux*"
agriyakhetarpal marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -55,6 +66,8 @@ 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 setuptools wheel # skip CasADi and CMake
CIBW_TEST_COMMAND: python -c "import pybamm; pybamm.IDAKLUSolver()"
agriyakhetarpal marked this conversation as resolved.
Show resolved Hide resolved

- name: Upload Windows wheels
uses: actions/upload-artifact@v3
Expand All @@ -63,16 +76,19 @@ jobs:
path: ./wheelhouse/*.whl
if-no-files-found: error

build_wheels:
name: Build wheels on ${{ matrix.os }}
build_macos_and_linux_wheels:
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 @@ -88,31 +104,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 numpy
# override; point to casadi install path so that it can be found by the repair command
CIBW_REPAIR_WHEEL_COMMAND_LINUX: >
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:$(python -c 'import casadi; print(casadi.__path__[0])')" 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 cmake casadi numpy &&
python scripts/fix_casadi_rpath_mac.py && scripts/fix_suitesparse_rpath_mac.sh
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
delocate-listdeps {wheel} &&
delocate-wheel -v -w {dest_dir} {wheel}
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 @@ -126,9 +143,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 @@ -140,9 +154,10 @@ 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_wheels, build_windows_wheels, build_sdist]
needs: [build_macos_and_linux_wheels, build_windows_wheels, build_sdist]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
Expand All @@ -151,7 +166,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 All @@ -171,7 +186,7 @@ jobs:
repository-url: https://test.pypi.org/legacy/

open_failure_issue:
needs: [build_windows_wheels, build_wheels, build_sdist]
needs: [build_windows_wheels, build_macos_and_linux_wheels, build_sdist]
name: Open an issue if build fails
if: ${{ always() && contains(needs.*.result, 'failure') }}
runs-on: ubuntu-latest
Expand Down
16 changes: 12 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,34 @@ if (NOT DEFINED USE_PYTHON_CASADI)
set(USE_PYTHON_CASADI TRUE)
endif()

# Use importlib to find the casadi path without importing it. This is useful
# to find the path for the build-time dependency, not the run-time dependency.
execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c
"import casadi as _; print(_.__path__[0])"
"import importlib.util; print(importlib.util.find_spec('casadi').submodule_search_locations[0])"
agriyakhetarpal marked this conversation as resolved.
Show resolved Hide resolved
agriyakhetarpal marked this conversation as resolved.
Show resolved Hide resolved
OUTPUT_VARIABLE CASADI_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)

if (CASADI_DIR)
file(TO_CMAKE_PATH ${CASADI_DIR} CASADI_DIR)
message("Found python casadi path: ${CASADI_DIR}")
message("Found Python casadi path: ${CASADI_DIR}")
endif()

if(${USE_PYTHON_CASADI})
message("Trying to link against python casadi package")
message("Trying to link against Python casadi package")
find_package(casadi CONFIG PATHS ${CASADI_DIR} REQUIRED)
else()
message("Trying to link against any casadi package apart from the python one")
message("Trying to link against any casadi package apart from the Python one")
set(CMAKE_IGNORE_PATH "${CASADI_DIR}/cmake")
find_package(casadi CONFIG REQUIRED)
endif()

set_target_properties(
agriyakhetarpal marked this conversation as resolved.
Show resolved Hide resolved
idaklu PROPERTIES
INSTALL_RPATH "${CASADI_DIR}"
INSTALL_RPATH_USE_LINK_PATH TRUE
)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR})
# Sundials
find_package(SUNDIALS REQUIRED)
Expand Down
71 changes: 0 additions & 71 deletions scripts/fix_casadi_rpath_mac.py

This file was deleted.

Loading