From ba8c814814d0e8ad23ed8c54820ae14b4c0d725f Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 11 Apr 2012 20:26:05 +0000 Subject: [PATCH] Use the Windows Registry to set PYTHONPATH Cantera's mechanism conversion scripts are now installed in the main Cantera directory, so processing should work fine as long as Python is on the path, whether or not the Cantera Python module is installed. --- SConstruct | 4 ++++ src/base/application.cpp | 21 +++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/SConstruct b/SConstruct index 85a2805b9..0680ae53e 100644 --- a/SConstruct +++ b/SConstruct @@ -1073,6 +1073,10 @@ if 'install' in COMMAND_LINE_TARGETS: # Data files install('$inst_datadir', mglob(env, pjoin('data','inputs'), 'cti', 'xml')) + # Converter scripts + install('$inst_bindir', 'interfaces/python/ck2cti.py') + install('$inst_bindir', 'interfaces/python/ctml_writer.py') + ### List of libraries needed to link to Cantera ### linkLibs = ['cantera'] linkSharedLibs = ['cantera_shared'] diff --git a/src/base/application.cpp b/src/base/application.cpp index c18ddd866..0be77c8fb 100644 --- a/src/base/application.cpp +++ b/src/base/application.cpp @@ -648,11 +648,24 @@ void Application::setDefaultDirectories() // 'templates' subdirectories of the main installation directory. std::string installDir; - readStringRegistryKey("SOFTWARE\\Cantera\\Cantera 2.0", "InstallDir", installDir, ""); - if (installDir != "") { - dirs.push_back(installDir + "data"); - dirs.push_back(installDir + "templates"); + readStringRegistryKey("SOFTWARE\\Cantera\\Cantera 2.0", + "InstallDir", installDir, ""); + if (installDir == "") { + return; } + dirs.push_back(installDir + "data"); + dirs.push_back(installDir + "templates"); + + // Scripts for converting mechanisms to CTI and CMTL formats are installed + // In the 'bin' subdirectory. Add that directory to the PYTHONPATH. + const char* old_pythonpath = getenv("PYTHONPATH"); + std::string pythonpath = "PYTHONPATH=" + installDir + "\\bin"; + if (old_pythonpath) { + pythonpath += ";"; + pythonpath.append(old_pythonpath); + } + putenv(pythonpath.c_str()); + #endif #ifdef DARWIN