From 3637cc1625795a1311669a23cffa7259d6ee8bb9 Mon Sep 17 00:00:00 2001 From: Ivo Steinbrecher Date: Fri, 22 Aug 2025 11:11:34 +0200 Subject: [PATCH] Allow custom python2 path --- src/cubitpy/conf.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/cubitpy/conf.py b/src/cubitpy/conf.py index cfa0f73..f018e95 100644 --- a/src/cubitpy/conf.py +++ b/src/cubitpy/conf.py @@ -135,14 +135,20 @@ def get_cubit_interpreter(cls): cubit_python_interpreter = python3_files[0] return cubit_python_interpreter else: + python2_path_env = get_path( + "CUBITPY_PYTHON2", os.path.isfile, throw_error=False + ) + if python2_path_env is not None: + return python2_path_env + if shutil.which("python2.7") is not None: return "python2.7" - imcs_python2_path = "/imcs/public/compsim/opt/Python-2.7.18/python" - if os.path.exists(imcs_python2_path): - return imcs_python2_path - - raise ValueError("Could not find a python2 interpreter") + raise ValueError( + "Could not find a python2 interpreter. " + "You can specify this by setting the environment variable " + "CUBITPY_PYTHON2 to the path of your python2 interpreter." + ) @classmethod def is_coreform(cls):