From e61ae11c900d7ef74b411421b8d970b23ed62087 Mon Sep 17 00:00:00 2001 From: martinjrobins Date: Thu, 12 May 2022 10:14:32 +0100 Subject: [PATCH 1/9] #2047 use fixed paths instead of rpath for klu scripy install --- scripts/install_KLU_Sundials.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install_KLU_Sundials.py b/scripts/install_KLU_Sundials.py index d13ca52088..756c42aef8 100755 --- a/scripts/install_KLU_Sundials.py +++ b/scripts/install_KLU_Sundials.py @@ -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 From 35fb6109529c8e9069a3759ad060a83c4ac181ea Mon Sep 17 00:00:00 2001 From: martinjrobins Date: Thu, 12 May 2022 11:00:18 +0100 Subject: [PATCH 2/9] #2047 fix casadi rpaths --- .github/workflows/build_wheels.yml | 3 ++- scripts/fix_casadi_rpath_mac.py | 32 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 scripts/fix_casadi_rpath_mac.py diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 51cb90dd76..2bfba95682 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -74,7 +74,8 @@ 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" CIBW_SKIP: pp* - uses: actions/upload-artifact@v2 diff --git a/scripts/fix_casadi_rpath_mac.py b/scripts/fix_casadi_rpath_mac.py new file mode 100644 index 0000000000..d0b29c7aec --- /dev/null +++ b/scripts/fix_casadi_rpath_mac.py @@ -0,0 +1,32 @@ +""" +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), +] +print(' '.join(["install_name_tool"] + install_name_tool_args)) +subprocess.run(["install_name_tool"] + install_name_tool_args) +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), +] +print(' '.join(["install_name_tool"] + install_name_tool_args)) +subprocess.run(["install_name_tool"] + install_name_tool_args) From 420a7f952a33d362b3846376b351eb7250534246 Mon Sep 17 00:00:00 2001 From: martinjrobins Date: Thu, 12 May 2022 11:43:32 +0100 Subject: [PATCH 3/9] #2047 put more debugging into fix_caadi_rpath_mac --- scripts/fix_casadi_rpath_mac.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/fix_casadi_rpath_mac.py b/scripts/fix_casadi_rpath_mac.py index d0b29c7aec..73657bfc31 100644 --- a/scripts/fix_casadi_rpath_mac.py +++ b/scripts/fix_casadi_rpath_mac.py @@ -20,13 +20,17 @@ 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)]) From 6e58cca193f6c139838889f03d2afd72dad2689a Mon Sep 17 00:00:00 2001 From: martinjrobins Date: Thu, 12 May 2022 12:04:20 +0100 Subject: [PATCH 4/9] #2047 try not require_arch in macos --- .github/workflows/build_wheels.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 2bfba95682..35094d1a24 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -76,6 +76,7 @@ jobs: CIBW_BEFORE_ALL_LINUX: "bash build_manylinux_wheels/install_sundials.sh 5.8.1 5.7.0" 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" + CIBW_REPAIR_WHEEL_COMMAND_MACOS: "delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel}" CIBW_SKIP: pp* - uses: actions/upload-artifact@v2 From 12729c6a5fdd72d8728e474e2788011f4c54a329 Mon Sep 17 00:00:00 2001 From: martinjrobins Date: Thu, 12 May 2022 12:47:04 +0100 Subject: [PATCH 5/9] #2047 increase cibuildwheel verbosity to debug windows build --- .github/workflows/build_wheels.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 35094d1a24..0ff278616f 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -37,6 +37,7 @@ jobs: 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_ARCHS: "AMD64" + CIBW_BUILD_VERBOSITY: 1 - uses: actions/upload-artifact@v2 with: @@ -76,6 +77,8 @@ jobs: CIBW_BEFORE_ALL_LINUX: "bash build_manylinux_wheels/install_sundials.sh 5.8.1 5.7.0" 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* From bb8ec034fa80846794aaee461d88334f996631ae Mon Sep 17 00:00:00 2001 From: martinjrobins Date: Thu, 12 May 2022 13:40:29 +0100 Subject: [PATCH 6/9] #2047 update casadi vcpkg to use static or dynamic linking --- vcpkg-configuration.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json index 378b18f6c3..802bd66efd 100644 --- a/vcpkg-configuration.json +++ b/vcpkg-configuration.json @@ -13,7 +13,7 @@ { "kind": "git", "repository": "https://github.com/pybamm-team/casadi-vcpkg-registry.git", - "baseline": "c44b0b834404dea4af79b8bc621ac513aefbd53d", + "baseline": "0545acc9a893b1d20709377c85b21c1f45d4c38a", "packages": [ "casadi" ] } ] From 944c4c2c3d5a4566f4960f7d99d717b39c57c949 Mon Sep 17 00:00:00 2001 From: martinjrobins Date: Thu, 12 May 2022 15:39:09 +0100 Subject: [PATCH 7/9] #2047 casadi uses ENABLE_STATIC --- vcpkg-configuration.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json index 802bd66efd..ecdff5f79d 100644 --- a/vcpkg-configuration.json +++ b/vcpkg-configuration.json @@ -13,7 +13,7 @@ { "kind": "git", "repository": "https://github.com/pybamm-team/casadi-vcpkg-registry.git", - "baseline": "0545acc9a893b1d20709377c85b21c1f45d4c38a", + "baseline": "70f49f3c22fee4874fb8a36ef1a559f2c185ef1f", "packages": [ "casadi" ] } ] From c522179dc40b2efe85cc619e9f156a6054cf6786 Mon Sep 17 00:00:00 2001 From: martinjrobins Date: Thu, 12 May 2022 16:58:13 +0100 Subject: [PATCH 8/9] #2047 use static-md for vcpkg deps --- .github/workflows/build_wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 0ff278616f..0894c9bc42 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -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" CIBW_BUILD_VERBOSITY: 1 From 46081dc808b17f2b92f0b01a9a9de613b5511903 Mon Sep 17 00:00:00 2001 From: martinjrobins Date: Thu, 12 May 2022 18:14:33 +0100 Subject: [PATCH 9/9] #2047 turn off verbosity --- .github/workflows/build_wheels.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 0894c9bc42..09154914d9 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -37,7 +37,6 @@ jobs: env: 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" - CIBW_BUILD_VERBOSITY: 1 - uses: actions/upload-artifact@v2 with: