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

I2047 linux wheel #2058

Merged
merged 9 commits into from
May 13, 2022
8 changes: 6 additions & 2 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
run: |
python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ENVIRONMENT: "PYBAMM_USE_VCPKG=ON VCPKG_ROOT_DIR=$cd/vcpkg VCPKG_DEFAULT_TRIPLET=x64-windows-static VCPKG_FEATURE_FLAGS=manifests,registries CMAKE_GENERATOR=\"Visual Studio 17 2022\" CMAKE_GENERATOR_PLATFORM=x64"
CIBW_ENVIRONMENT: "PYBAMM_USE_VCPKG=ON VCPKG_ROOT_DIR=$cd/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"

- uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -74,7 +74,11 @@ jobs:
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BEFORE_ALL_LINUX: "bash build_manylinux_wheels/install_sundials.sh 5.8.1 5.7.0"
CIBW_BEFORE_BUILD: "python -m pip install cmake casadi numpy"
CIBW_BEFORE_BUILD_LINUX: "python -m pip install cmake casadi numpy"
CIBW_BEFORE_BUILD_MACOS: "python -m pip install cmake casadi numpy && python scripts/fix_casadi_rpath_mac.py"
# got error "re.error: multiple repeat at position 104" on python 3.7 when --require-archs added, so remove
# it for mac
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel}"
CIBW_SKIP: pp*

- uses: actions/upload-artifact@v2
Expand Down
36 changes: 36 additions & 0 deletions scripts/fix_casadi_rpath_mac.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""
Removes the rpath from libcasadi.dylib in the casadi python install
and uses a fixed path

Used when building the wheels for macos
"""
import casadi
import os
import subprocess

casadi_dir = casadi.__path__[0]
print('Removing rpath references in python casadi install at', casadi_dir)

libcpp_name = "libc++.1.dylib"
libcppabi_name = "libc++abi.dylib"
libcasadi_name = "libcasadi.dylib"
install_name_tool_args = [
"-change",
os.path.join("@rpath", libcpp_name),
os.path.join(casadi_dir, libcpp_name),
os.path.join(casadi_dir, libcasadi_name),
]
subprocess.run(["otool"] + ["-L", os.path.join(casadi_dir, libcasadi_name)])
print(' '.join(["install_name_tool"] + install_name_tool_args))
subprocess.run(["install_name_tool"] + install_name_tool_args)
subprocess.run(["otool"] + ["-L", os.path.join(casadi_dir, libcasadi_name)])
install_name_tool_args = [
"-change",
os.path.join("@rpath", libcppabi_name),
os.path.join(casadi_dir, libcppabi_name),
os.path.join(casadi_dir, libcpp_name),
]
subprocess.run(["otool"] + ["-L", os.path.join(casadi_dir, libcpp_name)])
print(' '.join(["install_name_tool"] + install_name_tool_args))
subprocess.run(["install_name_tool"] + install_name_tool_args)
subprocess.run(["otool"] + ["-L", os.path.join(casadi_dir, libcpp_name)])
2 changes: 2 additions & 0 deletions scripts/install_KLU_Sundials.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ def download_extract_library(url, download_dir):
"-DKLU_INCLUDE_DIR={}".format(KLU_INCLUDE_DIR),
"-DKLU_LIBRARY_DIR={}".format(KLU_LIBRARY_DIR),
"-DCMAKE_INSTALL_PREFIX=" + install_dir,
# on mac use fixed paths rather than rpath
"-DCMAKE_INSTALL_NAME_DIR=" + KLU_LIBRARY_DIR,
]

# SUNDIALS are built within download_dir 'build_sundials' in the PyBaMM root
Expand Down
2 changes: 1 addition & 1 deletion vcpkg-configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{
"kind": "git",
"repository": "https://github.com/pybamm-team/casadi-vcpkg-registry.git",
"baseline": "c44b0b834404dea4af79b8bc621ac513aefbd53d",
"baseline": "70f49f3c22fee4874fb8a36ef1a559f2c185ef1f",
"packages": [ "casadi" ]
}
]
Expand Down