setup_shellrc now adds $DAMASK_ROOT/bin to the $PATH
in setup/setup_processing.py uncomment 3 lines to remove the links from your ~/bin
This commit is contained in:
parent
06176873e4
commit
41b8232695
|
@ -1,89 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os,sys,string,re
|
||||
from optparse import OptionParser
|
||||
|
||||
pathInfo = {\
|
||||
'acml': 'lib/acml4.4.0',
|
||||
'fftw': 'lib/fftw',
|
||||
'msc': '/msc',
|
||||
}
|
||||
|
||||
validShells = {\
|
||||
'bash':['.bashrc','.bash_profile'],
|
||||
'csh': ['.cshrc'],
|
||||
}
|
||||
|
||||
environment = {\
|
||||
'LD_LIBRARY_PATH': {'delete':'"acml"', # what keywords trigger item deletion from existing path
|
||||
'substitute':'[os.path.join(pathInfo["acml"],"ifort64_mp/lib"),\
|
||||
os.path.join(pathInfo["acml"],"ifort64/lib")]', # what to substitute for deleted path items
|
||||
'append': True, # whether new entries append to existing ${env}
|
||||
},
|
||||
'PYTHONPATH': {'delete':'os.path.join(DamaskRoot,"lib")',
|
||||
'substitute':'[os.path.join(DamaskRoot,"lib")]',
|
||||
'append': True,
|
||||
},
|
||||
'DAMASK_ROOT': {'delete':'DamaskRoot',
|
||||
'substitute':'[DamaskRoot]',
|
||||
'append': False,
|
||||
},
|
||||
}
|
||||
parser = OptionParser(usage="%prog [options]", description = """
|
||||
Sets up your shell resource to be compatible with DAMASK.
|
||||
""" + string.replace('$Id$','\n','\\n')
|
||||
)
|
||||
|
||||
parser.add_option("-s","--shell", type="string",
|
||||
dest = "shell", \
|
||||
help = "type of shell, e.g. "+', '.join(validShells.keys())+" [%default]")
|
||||
|
||||
parser.set_defaults(shell = 'bash')
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
DamaskRoot = os.path.normpath(os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),'../'))
|
||||
|
||||
try: # check for user-defined pathinfo
|
||||
file = open(os.path.join(DamaskRoot,'lib/pathinfo'))
|
||||
content = file.readlines()
|
||||
file.close()
|
||||
for line in content:
|
||||
pathinfo[line.split()[0].lower()] = os.path.normpath(line.split()[1])
|
||||
except:
|
||||
pass
|
||||
|
||||
theShell = options.shell.lower()
|
||||
theHome = os.getenv('USERPROFILE') or os.getenv('HOME')
|
||||
|
||||
if theShell == 'bash':
|
||||
for theRC in validShells[theShell]:
|
||||
thePath = os.path.join(theHome,theRC)
|
||||
if os.path.exists(thePath):
|
||||
rc = open(os.path.join(theHome,theRC))
|
||||
content = map(string.strip,rc.readlines())
|
||||
rc.close()
|
||||
|
||||
output = []
|
||||
for envVar in environment.keys(): environment[envVar]['matched'] = False
|
||||
|
||||
for line in content:
|
||||
for envVar,data in environment.items():
|
||||
m = re.search(r'^(.*?%s=)([^;]*)(.*)$'%envVar,line)
|
||||
if m:
|
||||
substitute = eval(data['substitute'])+[path for path in m.group(2).split(':') if eval(data['delete']) not in path]
|
||||
line = m.group(1)+':'.join(substitute)+m.group(3)
|
||||
environment[envVar]['matched'] = True
|
||||
|
||||
output.append(line)
|
||||
|
||||
for envVar,data in environment.items():
|
||||
if not data['matched']:
|
||||
output.append('export %s=%s'%(envVar,':'.join(eval(data['substitute'])+{True:['${%s}'%envVar],False:[]}[data['append']])))
|
||||
|
||||
rc = open(os.path.join(theHome,theRC),'w')
|
||||
rc.write('\n'.join(output)+'\n')
|
||||
rc.close()
|
||||
|
||||
elif theShell == 'csh':
|
||||
print 'csh not supported yet...'
|
|
@ -28,6 +28,10 @@ environment = {\
|
|||
'substitute':'[DamaskRoot]',
|
||||
'append': False,
|
||||
},
|
||||
'PATH': {'delete':'os.path.join(DamaskRoot,"bin")',
|
||||
'substitute':'[os.path.join(DamaskRoot,"bin")]',
|
||||
'append': True,
|
||||
},
|
||||
}
|
||||
parser = OptionParser(usage="%prog [options]", description = """
|
||||
Sets up your shell resource to be compatible with DAMASK.
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
|
||||
import os,sys,glob
|
||||
|
||||
import damask_tools; reload(damask_tools)
|
||||
damask_tools.DAMASK_TOOLS().check_env()
|
||||
|
||||
bin_link = { \
|
||||
'pre' : [
|
||||
'marc_addUserOutput.py',
|
||||
|
@ -56,22 +59,28 @@ execute = { \
|
|||
],
|
||||
}
|
||||
|
||||
#homedir = os.getenv('HOME')
|
||||
homedir = os.getenv('HOME')
|
||||
#basedir = os.path.join(os.path.dirname(sys.argv[0]),'..')
|
||||
homedir = os.getenv('DAMASK_ROOT')
|
||||
damask_root = os.getenv('DAMASK_ROOT')
|
||||
basedir = os.getenv('DAMASK_ROOT')+'/processing/'
|
||||
|
||||
for dir in bin_link:
|
||||
for file in bin_link[dir]:
|
||||
src = os.path.abspath(os.path.join(basedir,dir,file))
|
||||
if (file == ''):
|
||||
dst = os.path.abspath(os.path.join(homedir,'bin',dir))
|
||||
sym_link = os.path.abspath(os.path.join(damask_root,'bin',dir))
|
||||
else:
|
||||
dst = os.path.abspath(os.path.join(homedir,'bin',os.path.splitext(file)[0]))
|
||||
print src,'-->',dst
|
||||
if os.path.lexists(dst):
|
||||
os.remove(dst)
|
||||
os.symlink(src,dst)
|
||||
sym_link = os.path.abspath(os.path.join(damask_root,'bin',os.path.splitext(file)[0]))
|
||||
print sym_link,'-->',src
|
||||
if os.path.lexists(sym_link):
|
||||
os.remove(sym_link)
|
||||
os.symlink(src,sym_link)
|
||||
|
||||
#--- uncomment next lines to remove your old symbolic links in ~/bin
|
||||
#old_link=sym_link.replace(damask_root,homedir)
|
||||
#if os.path.lexists(old_link):
|
||||
# os.remove(old_link)
|
||||
|
||||
|
||||
for dir in compile:
|
||||
for file in compile[dir]:
|
||||
|
|
Loading…
Reference in New Issue