From b796e83f81752e0f4d28525d3590c89df07c2209 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 14 Dec 2011 02:20:19 +0000 Subject: [PATCH] Improved behavior of Python module when python isn't in the path --- Cantera/python/Cantera/__init__.py | 8 ++++++++ Cantera/src/base/ct2ctml.cpp | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Cantera/python/Cantera/__init__.py b/Cantera/python/Cantera/__init__.py index 1f05f195a..8fc7ba34b 100755 --- a/Cantera/python/Cantera/__init__.py +++ b/Cantera/python/Cantera/__init__.py @@ -12,6 +12,14 @@ from gases import * from set import set from importFromFile import * +import os as _os +import sys as _sys + +if not os.getenv('PYTHON_CMD'): + # Setting PYTHON_CMD here avoids issues with .cti -> .xml conversions + # in cases where the python interpreter isn't in the system path. + os.environ['PYTHON_CMD'] = _sys.executable + def writeCSV(f, list): """ Write list items to file 'f' in diff --git a/Cantera/src/base/ct2ctml.cpp b/Cantera/src/base/ct2ctml.cpp index 591d599fb..4064ed126 100644 --- a/Cantera/src/base/ct2ctml.cpp +++ b/Cantera/src/base/ct2ctml.cpp @@ -64,7 +64,7 @@ namespace ctml { if (!py) { const char* hm = getenv("HOME"); string home = stripws(string(hm)); - string cmd = string("source ")+home + string cmd = string(". ")+home +string("/setup_cantera &> /dev/null"); system(cmd.c_str()); py = getenv("PYTHON_CMD");