Configuration Helper Scripts

SAS Event Stream Processing includes two shell scripts to assist with configuring environment variables for running SAS Event Stream Processing. Using these scripts to run Python modules in SAS Micro Analytic Service is optional.
The script espenv_print prints a list of shell commands that can be cut and pasted into your .bashrc file or other shell script of your choice. The following is example output from espenv_print:
[develop]$ ../package-scripts/espenv_print -i sas -m 3.4

# The setting environment for an official SAS installation.
# The path name must point to the espenv_print location.
# -i indicates that the content must be stored in SAS or that it is SAS software.
# -m is required only if you plan to use Python, and it is followed
#  by the version number.
#
#
# Save or restore the previous PATH.
#
if [ ! -z ${ESPENV_PATH} ] ; then
   PATH=$ESPENV_PATH
else
   ESPENV_PATH=$PATH
fi

#
# Unset event stream processing specific variables.
#
unset    TKPATH
unset     ESP_I

#
# Set basic variables for event stream processing.
#
DFESP_HOME="/mnt/data/home/userid/work/esp"
ESP_I="-I /mnt/data/home/userid/work/esp/include/esptk
       -I /mnt/data/home/userid/work/esp/include/mas"

LD_LIBRARY_PATH="/mnt/data/home/userid/work/esp/lib:
                /mnt/data/home/userid/SASFoundation/sasexe"
           PATH="/mnt/data/home/userid/work/esp/bin:
                 /mnt/data/tools/java/jdk1.8.0_60/bin:
                 /mnt/data/tools/apache/apache-ant-1.8.2/bin:
                 /mnt/data/tools/maven/apache-maven-3.3.9/bin:
                 /mnt/data/tools/doxy/1.8.8/bin:
                 /mnt/data/tools/git/bin:
                 /opt/teradata/client/14.10/tbuild/bin:
                 /usr/lib64/qt-3.3/bin:/opt/rh/python27/root/usr/bin:
                 /usr/local/bin:/bin:/usr/bin:/usr/local/sbin:
                 /usr/sbin:/sbin:/mnt/data/home/userid/work/esp/develop/bin"

#
# Set the basic variables for event stream processing,
# SAS Micro Analytic Service, or Python.
#

source activate python34

PYTHONPATH=".:$CONDA_PREFIX/lib/python3.4:
            $CONDA_PREFIX/lib/python3.4/site-packages:
            $CONDA_PREFIX/lib/python3.4/site-packages/pandas:
            $CONDA_PREFIX/lib/python3.4/site-packages/numpy:
            $CONDA_PREFIX/lib/python3.4/site-packages/numpy/lib"

LD_LIBRARY_PATH="$CONDA_PREFIX/lib:$LD_LIBRARY_PATH"

export DFESP_HOME TKPATH ESP_I LD_LIBRARY_PATH PATH PYTHONPATH ESPENV_PATH
The script espenv can generate the same shell commands as espenv_print. However, instead of printing the commands to the console, it executes the commands, configuring the current shell to run Python modules in SAS Event Stream Processing.
To make Python configuration as convenient as possible, add the espenv function to your .bashrc file using the following steps. This makes the function available to call from any folder, as long as you are in a bash shell. Use the espenv function if you switch back and forth between Python 2.7 and Python 3.4. If you plan to use only one of the versions, add the output of espenv_print to your .bashrc file instead. This makes the configuration run automatically whenever you launch a bash shell.
  1. Open espenv_func and copy the code.
  2. Change directories to your home directory.
  3. Paste the code into your .bashrc file.
  4. Copy espenv_print to your home directory.
  5. Edit espenv_print and search for the following lines:
    #***********************************************************************
    # MODIFY PYTHONPATH (BELOW) WHENEVER PYTHON PACKAGES HAVE BEEN ADDED   *
    # OR REMOVED FROM YOUR ANACONDA PYTHON 3.4 ENVIRONMENT                 *
    #***********************************************************************
    PYTHONPATH='.:$CP/lib/python3.4:$CP/lib/python3.4/site-packages:$CP/lib/
                   python3.4/site-packages/numpy:$CP/lib/python3.4/site-packages
                   /numpy/lib:$CP/lib/python3.4/site-packages/sklearn'
  6. The script contains two lines that set PYTHONPATH, one for Python 3.4 and the other for Python 2.7. Edit the appropriate PYTHONPATH and add paths for each Python package that you have installed and intend to use. Be sure to separate each path with a colon. $CP represents the root location where packages are stored in your Anaconda environment (such as the folder called site-packages). espenv_print automatically retrieves this location from Anaconda when the script is executed.
    Note: Some Python packages require you to store more than one path because they store Python modules and executables in more than one folder.
  7. Save your changes.
Note: Here is an alternative method:
  1. Run espenv_print.
  2. Cut and paste the output into your .bashrc file.
  3. Append :$PATH to the end of the line that starts with PATH.
  4. Append the following to the end of LD_LIBRARY_PATH:
    :$LD_LIBRARY_PATH
For a complete description of these scripts and their options, see SAS Event Stream Processing: Deployment Guide.