Allows adding/overriding env vars in the execution context.
        :param kw: Key-value pairs
        :return: self
439748
def env(self, **kw):
        '''
        
        '''
        self._original_env = kw
        if self._env is None:
            self._env = dict(os.environ)
        self._env.update({k: unicode(v) for k, v in kw.iteritems()})
        return self
186436
public static void addEnvVarsFromContextForExec(final ExecTask execTask,
                                                    final Map<String, Map<String, String>> dataContext) {
        final Map<String, String> environment = generateEnvVarsFromContext(dataContext);

        if (null != environment) {
            for (final Map.Entry<String, String> entry : environment.entrySet()) {
                final String key = entry.getKey();
                if (null != key && null != entry.getValue()) {
                    final Environment.Variable env = new Environment.Variable();
                    env.setKey(key);
                    env.setValue(entry.getValue());
                    execTask.addEnv(env);
                }
            }
        }
    }
279070
public Launcher addEnvironmentVariable(final String key, final String value) {
        env.put(key, value);
        return this;
    }
289346
def make_simulated_env_fn(**env_kwargs):
  
  def env_fn(in_graph):
    class_ = SimulatedBatchEnv if in_graph else SimulatedBatchGymEnv
    return class_(**env_kwargs)
  return env_fn
210062
def env(*args, **kwargs):
    
    for arg in args:
        value = os.environ.get(arg, None)
        if value:
            return value
    return kwargs.get("default", "")
123664
def override_to_local_variable(enable=True):
    
    if enable:

        def custom_getter(getter, name, *args, **kwargs):
            _replace_global_by_local(kwargs)
            return getter(name, *args, **kwargs)

        with custom_getter_scope(custom_getter):
            yield
    else:
        yield
639496
def with_env(cls, env):
        
        new_cls = type(cls.__name__, cls.__bases__, dict(cls.__dict__))
        new_cls._env = env
        return new_cls
90267
def _preprocess_override(meth_types, base_types, meth_argspec, base_argspec):
    
    try:
        base_kw = base_argspec.keywords
        kw = meth_argspec.keywords
    except AttributeError:
        base_kw = base_argspec.varkw
        kw = meth_argspec.varkw
    try:
        kwonly = meth_argspec.kwonlyargs
        base_kwonly = base_argspec.kwonlyargs
    except AttributeError:
        kwonly = None
        base_kwonly = None
    if meth_argspec.varargs is None and base_argspec.varargs is None \
            and kw is None and base_kw is None \
            and kwonly is None and base_kwonly is None \
            and (meth_argspec.defaults is None or \
                len(meth_argspec.args) == len(base_argspec.args)):
        return meth_types, base_types
    arg_types = type_util.get_Tuple_params(meth_types[0])
    base_arg_types = type_util.get_Tuple_params(base_types[0])
    kw_off = len(meth_argspec.args)-1 # -1 for self
    if not meth_argspec.defaults is None and base_argspec.varargs is None:
        kw_off -= len(meth_argspec.defaults)
    base_kw_off = len(base_argspec.args)
    if base_argspec.varargs is None:
        base_kw_off -= 1 # one decrement anyway for self
    arg_types2 = list(arg_types[:kw_off])
    base_arg_types2 = list(base_arg_types[:base_kw_off])
    base_vargtype = None
    vargtype = None
    base_argnames = None
    argnames = None
    if not base_argspec.varargs is None or not base_kw is None:
        base_argnames = util.getargnames(base_argspec)[1:]
        if not base_argspec.varargs is None:
            base_vargtype = base_arg_types[base_argnames.index(base_argspec.varargs)]
            # Should have been already checked:
            assert not meth_argspec.varargs is None
    if not meth_argspec.varargs is None or not kw is None:
        argnames = util.getargnames(meth_argspec)[1:]
        if not meth_argspec.varargs is None:
            vargtype = arg_types[argnames.index(meth_argspec.varargs)]
    if not meth_argspec.defaults is None:
        pos = 0
        if not base_argspec.varargs is None:
            # fill up parent's types with varg type to account for child's defaults
            while len(arg_types2) > len(base_arg_types2):
                base_arg_types2.append(base_vargtype)
            base_arg_types2.append(base_vargtype) # restore one more for the actual vargtype
        else:
            # parent has no vargtype, so fill up child with default-types afap
            while len(arg_types2) < len(base_arg_types2) and \
                    pos < len(meth_argspec.defaults):
                arg_types2.append(arg_types[kw_off+pos])
                pos += 1
    while len(arg_types2) < len(base_arg_types2):
        arg_types2.append(vargtype)
    if not kw is None:
        kw_type = arg_types[argnames.index(kw)]
    if not base_kwonly is None:
        for name in base_kwonly:
            base_arg_types2.append(base_arg_types[base_argnames.index(name)])
            if name in argnames:
                arg_types2.append(arg_types[argnames.index(name)])
            else:
                arg_types2.append(kw_type)
    if not base_kw is None:
        base_arg_types2.append(base_arg_types[base_argnames.index(base_kw)])
        arg_types2.append(kw_type)
    return (typing.Tuple[tuple(arg_types2)], meth_types[1]), \
            (typing.Tuple[tuple(base_arg_types2)], base_types[1])
436178
def config(_config=None, **kwargs):
    
    if _config is None:
        _config = {}
    _config.update(kwargs)

    def wrapper(func):
        func._config = _config
        return func
    return wrapper
216165
private static EnvVars inherit(@Nonnull Map<String,String> overrides) {
        EnvVars m = new EnvVars(EnvVars.masterEnvVars);
        m.overrideExpandingAll(overrides);
        return m;
    }
423771
def set_env_variables(stack, grid, platform = grid)
      ENV['STACK'] = stack
      ENV['GRID'] = grid
      ENV['PLATFORM'] = platform
    end
717712
def get_thunk_env(self, k):
    
    if k not in self.__items:
      raise exceptions.EvaluationError('Unknown key: %r in tuple %r' % (k, self))
    x = self.__items[k]

    env = self.env(self)

    # Bind this to the tuple's parent environment
    if isinstance(x, framework.BindableThunk):
      return x.bind(self.__parent_env), env
    return x, env
999856
def add_common_cc_variables(env):
    
    if '_CCCOMCOM' not in env:
        env['_CCCOMCOM'] = '$CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS'
        # It's a hack to test for darwin here, but the alternative
        # of creating an applecc.py to contain this seems overkill.
        # Maybe someday the Apple platform will require more setup and
        # this logic will be moved.
        env['FRAMEWORKS'] = SCons.Util.CLVar('')
        env['FRAMEWORKPATH'] = SCons.Util.CLVar('')
        if env['PLATFORM'] == 'darwin':
            env['_CCCOMCOM'] = env['_CCCOMCOM'] + ' $_FRAMEWORKPATH'

    if 'CCFLAGS' not in env:
        env['CCFLAGS']   = SCons.Util.CLVar('')

    if 'SHCCFLAGS' not in env:
        env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
1058819
def substitute_environ(self):
        
        for attr_name in dir(self):
            if attr_name.startswith('_') or attr_name.upper() != attr_name:
                continue

            orig_value = getattr(self, attr_name)
            is_required = isinstance(orig_value, Required)
            orig_type = orig_value.v_type if is_required else type(orig_value)
            env_var_name = self._ENV_PREFIX + attr_name
            env_var = os.getenv(env_var_name, None)
            if env_var is not None:
                if issubclass(orig_type, bool):
                    env_var = env_var.upper() in ('1', 'TRUE')
                elif issubclass(orig_type, int):
                    env_var = int(env_var)
                elif issubclass(orig_type, Path):
                    env_var = Path(env_var)
                elif issubclass(orig_type, bytes):
                    env_var = env_var.encode()
                # could do floats here and lists etc via json
                setattr(self, attr_name, env_var)
            elif is_required and attr_name not in self._custom_settings:
                raise RuntimeError('The required environment variable "{0}" is currently not set, '
                                   'you\'ll need to run `source activate.settings.sh` '
                                   'or you can set that single environment variable with '
                                   '`export {0}="<value>"`'.format(env_var_name))
53131
def set_default_var(**vars):
    
    for k, v in vars.iteritems():
        current_context.vars.setdefault(k, v)
155757
def env(*vars, **kwargs):
    
    for v in vars:
        value = os.environ.get(v)
        if value:
            return value
    return kwargs.get('default', '')
783377
def add_env_var(self, key, value):
        
        self.manifest['env'][key] = value
        os.environ[key] = str(value)