mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-21 14:05:14 +02:00
[config] default stub install verbose
This commit is contained in:
parent
3460b967a2
commit
096254a49c
4 changed files with 46 additions and 9 deletions
|
|
@ -1,5 +1,18 @@
|
||||||
# This is the local installation configuration file for GPy
|
# For user specific changes edit $HOME/.config/GPy/user.cfg
|
||||||
|
|
||||||
[plotting]
|
# [parallel]
|
||||||
library = plotly
|
# Enable openmp support. This speeds up some computations, depending on the number
|
||||||
#library = matplotlib
|
# 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
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,8 @@ def change_plotting_library(lib):
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
except (ImportError, NameError):
|
except (ImportError, NameError):
|
||||||
config.set('plotting', 'library', 'none')
|
config.set('plotting', 'library', 'none')
|
||||||
raise
|
|
||||||
import warnings
|
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
|
from ..util.config import config
|
||||||
lib = config.get('plotting', 'library')
|
lib = config.get('plotting', 'library')
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,6 @@ except ImportError:
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# This is the default configuration file that always needs to be present.
|
# 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'))
|
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)
|
# This specifies configurations specific to the user (it is found in the user home directory)
|
||||||
home = os.getenv('HOME') or os.getenv('USERPROFILE')
|
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.
|
# Read in the given files.
|
||||||
config.readfp(open(default_file))
|
config.readfp(open(default_file))
|
||||||
config.read([local_file, user_file])
|
config.read([local_file, user_file])
|
||||||
|
|
||||||
if not config:
|
if not config:
|
||||||
raise ValueError("No configuration file found at either " + user_file + " or " + local_file + " or " + default_file + ".")
|
raise ValueError("No configuration file found at either " + user_file + " or " + local_file + " or " + default_file + ".")
|
||||||
|
|
|
||||||
26
setup.py
26
setup.py
|
|
@ -146,3 +146,29 @@ setup(name = 'GPy',
|
||||||
'Programming Language :: Python :: 2.7',
|
'Programming Language :: Python :: 2.7',
|
||||||
'Topic :: Scientific/Engineering :: Artificial Intelligence']
|
'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))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue