Created
June 20, 2012 20:36
-
-
Save mgmarino/2962053 to your computer and use it in GitHub Desktop.
Wrap Python calls for use on SLAC batch system (64-bit rhel5)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Usage: | |
# Make sure this script is executable (chmod +x) and then use it in place of | |
# 'python' when submitting batch jobs or on 64-bit machines. | |
# | |
# If it is in your path (for example in your ~/bin directory and ~/bin is in your path), you | |
# can simply put: | |
# | |
# #!/usr/bin/env wrap_python.sh | |
# | |
# as the first line in your python file. | |
BASEDIR=/afs/slac.stanford.edu/package/tww/prod/i386_linux26/TWWfsw | |
REPLACEDIR=/opt/TWWfsw | |
PYTHON=${BASEDIR}/python25/bin/python | |
PYTHONPACKAGES=${BASEDIR}/python25/lib/python2.5 | |
PYTHONLIBDIR=${PYTHONPACKAGES}/config | |
ROOTCONFIG=/afs/slac.stanford.edu/package/cernroot/vol35/52800svn/Linux26SL5_i386_gcc412/bin/root-config | |
# Following defines only the needed packages for python, one may need to append to this list | |
NEEDEDPACKAGES="numpy12 libatlas36 readline52" | |
# Can comment the following if setup tools aren't needed | |
NEEDEDPACKAGES+=" setuptools06" | |
# Following needed for matplotlib | |
NEEDEDPACKAGES+=" matplotlib09 libopenssl098" | |
# Grab paths to prepend to LD_LIBRARY_PATH | |
for i in ${NEEDEDPACKAGES}; do | |
ADDLIBPATH=${BASEDIR}/$i/lib:${ADDLIBPATH:=""} | |
done | |
# Grab sys.path to put in PYTHONPATH | |
TEMPPATHS=`${PYTHON} -c "import sys; print ':'.join([x.replace('${REPLACEDIR}', '${BASEDIR}') for x in sys.path]) "` | |
LD_LIBRARY_PATH=${LD_LIBRARY_PATH:=""} | |
LD_LIBRARY_PATH=${ADDLIBPATH}:${PYTHONLIBDIR}:${LD_LIBRARY_PATH} | |
PYTHONPATH=${PYTHONPACKAGES}:`${ROOTCONFIG} --libdir`:${TEMPPATHS} ${PYTHON} "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment