From 881800126fa968c32b1968bbb21920ecbd39021a Mon Sep 17 00:00:00 2001 From: James Hensman Date: Thu, 5 Dec 2013 13:49:38 -0500 Subject: [PATCH] many dramatic cahnges. at least it import without error. --- GPy/gpy_config.cfg | 7 +++++++ GPy/util/config.py | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 GPy/gpy_config.cfg create mode 100644 GPy/util/config.py diff --git a/GPy/gpy_config.cfg b/GPy/gpy_config.cfg new file mode 100644 index 00000000..d52edd28 --- /dev/null +++ b/GPy/gpy_config.cfg @@ -0,0 +1,7 @@ +# This is the configuration file for GPy + +[parallel] +# Enable openmp support. This speeds up some computations, depending on the number +# of cores available. Setting up a compiler with openmp support can be difficult on +# some platforms, hence this option. +openmp=False diff --git a/GPy/util/config.py b/GPy/util/config.py new file mode 100644 index 00000000..02796e0b --- /dev/null +++ b/GPy/util/config.py @@ -0,0 +1,22 @@ +# +# This loads the configuration +# +import ConfigParser +import os +config = ConfigParser.ConfigParser() + +home = os.getenv('HOME') or os.getenv('USERPROFILE') +user_file = os.path.join(home,'.gpy_config.cfg') +default_file = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'gpy_config.cfg')) +print user_file, os.path.isfile(user_file) +print default_file, os.path.isfile(default_file) + +# 1. check if the user has a ~/.gpy_config.cfg +if os.path.isfile(user_file): + config.read(user_file) +elif os.path.isfile(default_file): + # 2. if not, use the default one + config.read(default_file) +else: + #3. panic + raise ValueError, "no configuration file found"