diff --git a/GPy/installation.cfg b/GPy/installation.cfg index d3b20c32..8458a86b 100644 --- a/GPy/installation.cfg +++ b/GPy/installation.cfg @@ -1,5 +1,18 @@ -# This is the local installation configuration file for GPy +# For user specific changes edit $HOME/.config/GPy/user.cfg -[plotting] -library = plotly -#library = matplotlib +# [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 by default it is off. +# openmp = False # True + +# [datasets] +# location for the local data cache +# dir=$HOME/tmp/GPy-datasets/ # Any other path you choose + +# [cython] +# working = True # False + + +# [plotting] +# library = matplotlib # plotly diff --git a/GPy/plotting/__init__.py b/GPy/plotting/__init__.py index 5edbb9e0..0fe5ba07 100644 --- a/GPy/plotting/__init__.py +++ b/GPy/plotting/__init__.py @@ -23,9 +23,8 @@ def change_plotting_library(lib): #=========================================================================== except (ImportError, NameError): config.set('plotting', 'library', 'none') - raise import warnings - #warnings.warn(ImportWarning("{} not available, install newest version of {} for plotting".format(lib, lib))) + warnings.warn(ImportWarning("{} not available, install newest version of {} for plotting".format(lib, lib))) from ..util.config import config lib = config.get('plotting', 'library') diff --git a/GPy/util/config.py b/GPy/util/config.py index 312d6991..c2b581f7 100644 --- a/GPy/util/config.py +++ b/GPy/util/config.py @@ -12,8 +12,6 @@ except ImportError: config = configparser.ConfigParser() - - # This is the default configuration file that always needs to be present. default_file = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'defaults.cfg')) @@ -23,10 +21,11 @@ local_file = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'in # This specifies configurations specific to the user (it is found in the user home directory) home = os.getenv('HOME') or os.getenv('USERPROFILE') -user_file = os.path.join(home,'.gpy_user.cfg') +user_file = os.path.join(home,'.config','gpy', 'user.cfg') # Read in the given files. config.readfp(open(default_file)) config.read([local_file, user_file]) + if not config: raise ValueError("No configuration file found at either " + user_file + " or " + local_file + " or " + default_file + ".") diff --git a/setup.py b/setup.py index 863c61a7..fa8f7e7c 100644 --- a/setup.py +++ b/setup.py @@ -146,3 +146,29 @@ setup(name = 'GPy', 'Programming Language :: Python :: 2.7', 'Topic :: Scientific/Engineering :: Artificial Intelligence'] ) + + +# Check config files and settings: +local_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'GPy', 'installation.cfg')) +home = os.getenv('HOME') or os.getenv('USERPROFILE') +user_file = os.path.join(home,'.config', 'GPy', 'user.cfg') + +print("") +if not os.path.exists(user_file): + # Does an old config exist? + old_user_file = os.path.join(home,'.gpy_user.cfg') + if os.path.exists(old_user_file): + # Move it to new location: + print("GPy: Found old config file, moving to new location {}".format(user_file)) + os.rename(old_user_file, user_file) + else: + # No config file exists, save informative stub to user config folder: + print("GPy: Saving user configuration file to {}".format(user_file)) + if not os.path.exists(os.path.dirname(user_file)): + os.makedirs(os.path.dirname(user_file)) + with open(user_file, 'w') as f: + with open(local_file, 'r') as l: + tmp = l.read() + f.write(tmp) +else: + print("GPy: User configuration file at location {}".format(user_file)) \ No newline at end of file