Build environment variables suitable for passing to the Model.
351759
def _build_environ(self) -> Dict[str, Optional[str]]:
        
        d: Dict[str, Optional[str]] = {}

        if self.__config__.case_insensitive:
            env_vars = {k.lower(): v for k, v in os.environ.items()}
        else:
            env_vars = cast(Dict[str, str], os.environ)

        for field in self.__fields__.values():
            if field.has_alias:
                env_name = field.alias
            else:
                env_name = self.__config__.env_prefix + field.name.upper()

            env_name_ = env_name.lower() if self.__config__.case_insensitive else env_name
            env_val = env_vars.get(env_name_, None)

            if env_val:
                if field.is_complex():
                    try:
                        env_val = json.loads(env_val)
                    except ValueError as e:
                        raise SettingsError(f'error parsing JSON for "{env_name}"') from e
                d[field.alias] = env_val
        return d
1197029
def to_env_vars(self):
        

        env = {
            'hosts': self.hosts, 'network_interface_name': self.network_interface_name,
            'hps': self.hyperparameters, 'user_entry_point': self.user_entry_point,
            'framework_params': self.additional_framework_parameters,
            'resource_config': self.resource_config, 'input_data_config': self.input_data_config,
            'output_data_dir': self.output_data_dir,
            'channels': sorted(self.channel_input_dirs.keys()),
            'current_host': self.current_host, 'module_name': self.module_name,
            'log_level': self.log_level,
            'framework_module': self.framework_module, 'input_dir': self.input_dir,
            'input_config_dir': self.input_config_dir, 'output_dir': self.output_dir,
            'num_cpus': self.num_cpus,
            'num_gpus': self.num_gpus, 'model_dir': self.model_dir, 'module_dir': self.module_dir,
            'training_env': dict(self), 'user_args': self.to_cmd_args(),
            'output_intermediate_dir': self.output_intermediate_dir
        }

        for name, path in self.channel_input_dirs.items():
            env['channel_%s' % name] = path

        for key, value in self.hyperparameters.items():
            env['hp_%s' % key] = value

        return _mapping.to_env_vars(env)
273507
def generate(env):
    """"""
    SCons.Tool.createStaticLibBuilder(env)

    # Set-up ms tools paths
    msvc_setup_env_once(env)

    env['AR']          = 'lib'
    env['ARFLAGS']     = SCons.Util.CLVar('/nologo')
    env['ARCOM']       = "${TEMPFILE('$AR $ARFLAGS /OUT:$TARGET $SOURCES','$ARCOMSTR')}"
    env['LIBPREFIX']   = ''
    env['LIBSUFFIX']   = '.lib'
625023
@Override
    public void buildEnvironment(Run<?,?> build, EnvVars env) {
        env.put(name,originalFileName);
    }
974916
def generate(env):
    """"""
    env['BUILDERS']['RMIC'] = RMICBuilder

    env['RMIC']            = 'rmic'
    env['RMICFLAGS']       = SCons.Util.CLVar('')
    env['RMICCOM']         = '$RMIC $RMICFLAGS -d ${TARGET.attributes.java_lookupdir} -classpath ${SOURCE.attributes.java_classdir} ${SOURCES.attributes.java_classname}'
    env['JAVACLASSSUFFIX']  = '.class'
527445
def write_env_vars(env_vars=None):  # type: (dict) -> None
    
    env_vars = env_vars or {}
    env_vars['PYTHONPATH'] = ':'.join(sys.path)

    for name, value in env_vars.items():
        os.environ[name] = value
783377
def add_env_var(self, key, value):
        
        self.manifest['env'][key] = value
        os.environ[key] = str(value)
661237
def set_os_environ(variables_mapping):
    
    for variable in variables_mapping:
        os.environ[variable] = variables_mapping[variable]
        logger.log_debug("Set OS environment variable: {}".format(variable))
991738
def _format_envvars(ctx):
    """"""
    params = [x for x in ctx.command.params if getattr(x, 'envvar')]

    for param in params:
        yield '.. _{command_name}-{param_name}-{envvar}:'.format(
            command_name=ctx.command_path.replace(' ', '-'),
            param_name=param.name,
            envvar=param.envvar,
        )
        yield ''
        for line in _format_envvar(param):
            yield line
        yield ''
1277928
def generate(env):
    """"""
    SCons.Tool.createStaticLibBuilder(env)
    
    if env.Detect('CC'):
        env['AR']          = 'CC'
        env['ARFLAGS']     = SCons.Util.CLVar('-ar')
        env['ARCOM']       = '$AR $ARFLAGS -o $TARGET $SOURCES'
    else:
        env['AR']          = 'ar'
        env['ARFLAGS']     = SCons.Util.CLVar('r')
        env['ARCOM']       = '$AR $ARFLAGS $TARGET $SOURCES'
        
    env['SHLINK']      = '$LINK'
    env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared')
    env['SHLINKCOM']   = '$SHLINK $SHLINKFLAGS -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS'
    env['LIBPREFIX']   = 'lib'
    env['LIBSUFFIX']   = '.a'
664330
def create_environment(preamble):
    
    environment = copy.deepcopy(os.environ)
    for line in preamble:
        logging.debug(line)
        if "=" in line and not line.startswith("#"):
            tmp = line.split("=")
            key = tmp[0].strip()
            value = tmp[1].strip()
            logging.debug(
                "Found variable {} with value {}".format(key, value))
            environment.update({key: value})
    logging.debug("Env {}".format(environment))
    return environment
1290790
def _settings_from_env(self):
        """"""
        return {attr: self._val_from_env(env, attr)
                for env, attr in const.ENV_TO_ATTR.items()
                if env in os.environ}
1348807
def get_env_variable(var_name, default=None):
    """"""
    try:
        return os.environ[var_name]
    except KeyError:
        if default is None:
            error_msg = "Set the %s environment variable" % var_name
            raise ImproperlyConfigured(error_msg)
        else:
            return default
1314361
def generate(env):
    """"""
    link.generate(env)
    
    env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -G')

    env['RPATHPREFIX'] = '-R'
    env['RPATHSUFFIX'] = ''
    env['_RPATH'] = '${_concat(RPATHPREFIX, RPATH, RPATHSUFFIX, __env__)}'

    # Support for versioned libraries
    link._setup_versioned_lib_variables(env, tool = 'sunlink', use_soname = True) 
    env['LINKCALLBACKS'] = link._versioned_lib_callbacks()
270047
def setenv(self, variable, value):
    '''
    '''
    os.environ[variable] = value
    os.putenv(variable, value)
    bot.debug('%s set to %s' % (variable, value))
200411
def generate(env):
    """"""
    try:
        bld = env['BUILDERS']['Rpm']
    except KeyError:
        bld = RpmBuilder
        env['BUILDERS']['Rpm'] = bld

    env.SetDefault(RPM          = 'LC_ALL=C rpmbuild')
    env.SetDefault(RPMFLAGS     = SCons.Util.CLVar('-ta'))
    env.SetDefault(RPMCOM       = rpmAction)
    env.SetDefault(RPMSUFFIX    = '.rpm')
725318
def run(self):
        
        env_name = self.env_name or BUILD_JSON_ENV
        try:
            build_cfg_json = os.environ[env_name]
        except KeyError:
            self.log.error("build config not found in env variable '%s'", env_name)
            return None
        else:
            try:
                return self.substitute_configuration(json.loads(build_cfg_json))
            except ValueError:
                self.log.error("couldn't load build config: invalid json")
                return None