def environment_modifications_for_spec(spec, view=None):
    """List of environment (shell) modifications to be processed for spec.

    This list is specific to the location of the spec or its projection in
    the view."""
    spec = spec.copy()
    if view and not spec.external:
        spec.prefix = prefix.Prefix(view.view().get_projection_for_spec(spec))

    # generic environment modifications determined by inspecting the spec
    # prefix
    env = environment.inspect_path(
        spec.prefix,
        prefix_inspections(spec.platform),
        exclude=environment.is_system_path
    )

    # Let the extendee/dependency modify their extensions/dependents
    # before asking for package-specific modifications
    env.extend(
        build_env.modifications_from_dependencies(
            spec, context='run'
        )
    )

    # Package specific modifications
    build_env.set_module_variables_for_package(spec.package)
    spec.package.setup_run_environment(env)

    return env
Esempio n. 2
0
def environment_modifications_for_spec(spec,
                                       view=None,
                                       set_package_py_globals=True):
    """List of environment (shell) modifications to be processed for spec.

    This list is specific to the location of the spec or its projection in
    the view.

    Args:
        spec (spack.spec.Spec): spec for which to list the environment modifications
        view: view associated with the spec passed as first argument
        set_package_py_globals (bool): whether or not to set the global variables in the
            package.py files (this may be problematic when using buildcaches that have
            been built on a different but compatible OS)
    """
    spec = spec.copy()
    if view and not spec.external:
        spec.prefix = prefix.Prefix(view.get_projection_for_spec(spec))

    # generic environment modifications determined by inspecting the spec
    # prefix
    env = environment.inspect_path(spec.prefix,
                                   prefix_inspections(spec.platform),
                                   exclude=environment.is_system_path)

    # Let the extendee/dependency modify their extensions/dependents
    # before asking for package-specific modifications
    env.extend(
        spack.build_environment.modifications_from_dependencies(
            spec, context='run',
            set_package_py_globals=set_package_py_globals))

    if set_package_py_globals:
        spack.build_environment.set_module_variables_for_package(spec.package)

    spec.package.setup_run_environment(env)

    return env