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.
This commit is contained in:
Ray Speth 2012-04-11 20:26:05 +00:00
parent 2076f37421
commit ba8c814814
2 changed files with 21 additions and 4 deletions

View file

@ -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']

View file

@ -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