Skip to content

Commit

Permalink
pybamm-team#3100 Try Python casadi 3.6.4 for Windows wheels
Browse files Browse the repository at this point in the history
  • Loading branch information
agriyakhetarpal committed Dec 8, 2023
1 parent 8608682 commit 6e84114
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +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 setuptools wheel # skip CasADi and CMake
CIBW_BEFORE_BUILD: python -m pip install setuptools wheel casadi # skip CMake
CIBW_TEST_COMMAND: python -c "import pybamm; pybamm.IDAKLUSolver()"

- name: Upload Windows wheels
Expand Down
20 changes: 4 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ pybind11_add_module(idaklu
pybamm/solvers/c_solvers/idaklu.cpp
)

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(
Expand All @@ -72,19 +68,11 @@ execute_process(
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}")
endif()
file(TO_CMAKE_PATH ${CASADI_DIR} CASADI_DIR)
message("Found Python casadi path: ${CASADI_DIR}")

if(${USE_PYTHON_CASADI})
message("Trying to link against Python casadi package")
find_package(casadi CONFIG PATHS ${CASADI_DIR} REQUIRED NO_DEFAULT_PATH)
else()
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()
message("Trying to link against Python casadi package")
find_package(casadi CONFIG PATHS ${CASADI_DIR} REQUIRED NO_DEFAULT_PATH)

set_target_properties(
idaklu PROPERTIES
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
requires = [
"setuptools>=64",
"wheel",
# On Windows, use the CasADi vcpkg registry and CMake bundled from MSVC
"casadi>=3.6.3; platform_system!='Windows'",
# On Windows, use CMake bundled from MSVC
"casadi>=3.6.3",
"cmake; platform_system!='Windows'",
]
build-backend = "setuptools.build_meta"
Expand Down
6 changes: 0 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,10 @@ def run(self):
if not self.extensions:
return

if system() == "Windows":
use_python_casadi = False
else:
use_python_casadi = True

build_type = os.getenv("PYBAMM_CPP_BUILD_TYPE", "RELEASE")
cmake_args = [
"-DCMAKE_BUILD_TYPE={}".format(build_type),
"-DPYTHON_EXECUTABLE={}".format(sys.executable),
"-DUSE_PYTHON_CASADI={}".format("TRUE" if use_python_casadi else "FALSE"),
]
if self.suitesparse_root:
cmake_args.append(
Expand Down
6 changes: 0 additions & 6 deletions vcpkg-configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
"repository": "https://github.com/pybamm-team/sundials-vcpkg-registry.git",
"baseline": "af9f5e4bc730bf2361c47f809dcfb733e7951faa",
"packages": ["sundials"]
},
{
"kind": "git",
"repository": "https://github.com/pybamm-team/casadi-vcpkg-registry.git",
"baseline": "70f49f3c22fee4874fb8a36ef1a559f2c185ef1f",
"packages": ["casadi"]
}
]
}
1 change: 0 additions & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "pybamm",
"version-string": "23.9",
"dependencies": [
"casadi",
{
"name": "sundials",
"default-features": false,
Expand Down

0 comments on commit 6e84114

Please sign in to comment.