diff --git a/pymbolic/interop/maxima.py b/pymbolic/interop/maxima.py index 9a1fc448ef1824873d1cef8ef2971cefa5fa016e..2995767a0826d737fb4b3c0469b0ecde67b781e7 100644 --- a/pymbolic/interop/maxima.py +++ b/pymbolic/interop/maxima.py @@ -45,38 +45,6 @@ import numpy as np from pymbolic.mapper.stringifier import StringifyMapper from pymbolic.parser import Parser as ParserBase, FinalizedTuple -# {{{ check for maxima executable - -def _find_maxima_executable(): - import os - - def is_executable(filename): - return os.path.isfile(filename) and os.access(filename, os.X_OK) - - global FOUND_MAXIMA - - executable = os.environ.get("PYMBOLIC_MAXIMA_EXECUTABLE", "maxima") - - FOUND_MAXIMA = False - if is_executable(executable): - FOUND_MAXIMA = True - else: - executable = os.path.basename(executable) - try: - import shutil - FOUND_MAXIMA = bool(shutil.which(executable)) - except AttributeError: - for path in os.environ["PATH"].split(os.pathsep): - filename = os.path.join(path, executable) - if is_executable(filename): - FOUND_MAXIMA = True - break - - -_find_maxima_executable() - -# }}} - IN_PROMPT_RE = re.compile(br"\(%i([0-9]+)\) ") OUT_PROMPT_RE = re.compile(br"\(%o([0-9]+)\) ") ERROR_PROMPT_RE = re.compile( diff --git a/test/test_maxima.py b/test/test_maxima.py index 7a6a7e0073db500aee539054c0137a01585205ae..ce83c4ed1c39306e91c2caa367c5b0d6b3a0caee 100644 --- a/test/test_maxima.py +++ b/test/test_maxima.py @@ -24,7 +24,6 @@ THE SOFTWARE. import pytest from pymbolic.interop.maxima import MaximaKernel -from pymbolic.interop.maxima import FOUND_MAXIMA @pytest.mark.skipif(not FOUND_MAXIMA, reason="cannot find maxima executable") @@ -38,6 +37,39 @@ def test_kernel(): knl.shutdown() +# {{{ check for maxima executable + +def _find_maxima_executable(): + import os + + def is_executable(filename): + return os.path.isfile(filename) and os.access(filename, os.X_OK) + + global FOUND_MAXIMA + + executable = os.environ.get("PYMBOLIC_MAXIMA_EXECUTABLE", "maxima") + + FOUND_MAXIMA = False + if is_executable(executable): + FOUND_MAXIMA = True + else: + executable = os.path.basename(executable) + try: + import shutil + FOUND_MAXIMA = bool(shutil.which(executable)) + except AttributeError: + for path in os.environ["PATH"].split(os.pathsep): + filename = os.path.join(path, executable) + if is_executable(filename): + FOUND_MAXIMA = True + break + + +_find_maxima_executable() + +# }}} + + @pytest.fixture def knl(request): pytest.importorskip("pexpect")