From c7528c464ed5e242001de72da26f7b96f138faae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kl=C3=B6ckner?= <inform@tiker.net> Date: Thu, 14 Jun 2018 16:07:40 -0400 Subject: [PATCH] Demote Maxima finding to a test-only thing --- pymbolic/interop/maxima.py | 32 -------------------------------- test/test_maxima.py | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/pymbolic/interop/maxima.py b/pymbolic/interop/maxima.py index 9a1fc44..2995767 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 7a6a7e0..ce83c4e 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") -- GitLab