Skip to content

Instantly share code, notes, and snippets.

@nhoffman
Created October 5, 2015 16:50
Show Gist options
  • Save nhoffman/d5a56a7a93fb12effee5 to your computer and use it in GitHub Desktop.
Save nhoffman/d5a56a7a93fb12effee5 to your computer and use it in GitHub Desktop.
import os
import sys
import ConfigParser
from os import path, environ
import glob
import itertools
venv = environ.get('VIRTUAL_ENV')
if not venv:
sys.exit('--> an active virtualenv is required'.format(venv))
# requirements installed in the virtualenv
from SCons.Script import (
ARGUMENTS, Variables, Decider, Depends, EnumVariable,
PathVariable, Help, BoolVariable, Precious, Dir)
# check timestamps before calculating md5 checksums
Decider('MD5-timestamp')
vars = Variables()
# declare variables for the environment
vars.Add(PathVariable('out', 'Path to output directory',
'output', PathVariable.PathIsDirCreate))
vars.Add('nproc', 'Number of concurrent processes', default=12)
# Provides access to options prior to instantiation of env object
# below; it's better to access variables through the env object.
varargs = dict({opt.key: opt.default for opt in vars.options}, **vars.args)
truevals = {True, 'yes', 'y', 'True', 'true', 't'}
nproc = varargs['nproc']
#####################################################################
######################## input data ###############################
#####################################################################
#####################################################################
######################### end input data ##########################
#####################################################################
# Explicitly define PATH, giving preference to local executables; it's
# best to use absolute paths for non-local executables rather than add
# paths here to avoid accidental introduction of external
# dependencies. Environment variables are inherited from the parent
# shell from which scons is run.
environment_variables = dict(
os.environ,
PATH=':'.join([
'bin',
path.join(venv, 'bin'),
'/app/bin', # provides R
'/usr/local/bin', '/usr/bin', '/bin']),
OMP_NUM_THREADS=nproc,
R_LIBS_USER=path.join(path.split(venv)[0], 'R', 'R.%v-library'),
)
env = Environment(
ENV=environment_variables,
variables=vars,
use_cluster=False,
SHELL='bash'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment