-
Notifications
You must be signed in to change notification settings - Fork 10
/
config.py
66 lines (60 loc) · 1.97 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import os
import sys
import configparser
##### USER CONFIGURATION SECTION #####
# Set any of the below to False to disable the build and install of
# the corresponding module.
nleq2 = True
pitcon = True
##### END USER CONFIGURATION SECTION #####
if 'PYSCES_SKIP' in os.environ:
if 'nleq2' in os.environ['PYSCES_SKIP']:
nleq2 = False
if 'pitcon' in os.environ['PYSCES_SKIP']:
pitcon = False
local_path = os.path.dirname(os.path.abspath(__file__))
os.chdir(local_path)
# Default configurations for the pyscfg.ini files
config = {
"gnuplot_dir": None,
"silentstart": False,
"change_dir_on_start": False,
"custom_datatype": None,
}
def writeConfig(local_path, config={}):
output = ''
cp = configparser.ConfigParser()
# PySCeS internal setup
cp.add_section('Pysces')
for key in config:
print(repr(key) + ' :: ' + str(config[key]), file=sys.stderr)
cp.set('Pysces', key, str(config[key]))
# add configuration data
cp.add_section('PyscesConfig')
cp.set('PyscesConfig', 'matplotlib', 'True')
# OSX patch thanks to AF
if os.sys.platform == 'darwin':
cp.set('PyscesConfig', 'matplotlib_backend', 'MacOSX')
else:
cp.set('PyscesConfig', 'matplotlib_backend', 'TkAgg')
cp.set('PyscesConfig', 'gnuplot', 'False')
# Built in modules
cp.add_section('PyscesModules')
if not pitcon:
cp.set('PyscesModules', 'pitcon', 'False')
else:
cp.set('PyscesModules', 'pitcon', 'True')
output += 'pitcon '
# PySCeS external module setup
cp.add_section('ExternalModules')
if not nleq2:
cp.set('ExternalModules', 'nleq2', 'False')
else:
cp.set('ExternalModules', 'nleq2', 'True')
output += 'nleq2 '
with open(os.path.join(local_path, 'pysces', 'pyscfg.ini'), 'w') as cfgfile:
cp.write(cfgfile)
return output
output = writeConfig(local_path, config)
print('Default configuration file installed', file=sys.stderr)
print(output)