Skip to content

Commit

Permalink
pybamm-team#3558 Import casadi using importlib instead
Browse files Browse the repository at this point in the history
  • Loading branch information
agriyakhetarpal committed Nov 27, 2023
1 parent 71e6245 commit 1d08d0f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ 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])"
OUTPUT_VARIABLE CASADI_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)

Expand Down

0 comments on commit 1d08d0f

Please sign in to comment.