def test_path_manipulation(self): env = EnvironmentModifications() env.append_path('PATH_LIST', '/path/last') env.prepend_path('PATH_LIST', '/path/first') env.append_path('EMPTY_PATH_LIST', '/path/middle') env.append_path('EMPTY_PATH_LIST', '/path/last') env.prepend_path('EMPTY_PATH_LIST', '/path/first') env.append_path('NEWLY_CREATED_PATH_LIST', '/path/middle') env.append_path('NEWLY_CREATED_PATH_LIST', '/path/last') env.prepend_path('NEWLY_CREATED_PATH_LIST', '/path/first') env.remove_path('REMOVE_PATH_LIST', '/remove/this') env.remove_path('REMOVE_PATH_LIST', '/duplicate/') env.apply_modifications() self.assertEqual( '/path/first:/path/second:/path/third:/path/last', os.environ['PATH_LIST'] ) self.assertEqual( '/path/first:/path/middle:/path/last', os.environ['EMPTY_PATH_LIST'] ) self.assertEqual( '/path/first:/path/middle:/path/last', os.environ['NEWLY_CREATED_PATH_LIST'] ) self.assertEqual('/a/b:/a/c:/a/d:/f/g', os.environ['REMOVE_PATH_LIST'])
def clean_environment(): # Stuff in here sanitizes the build environment to eliminate # anything the user has set that may interfere. We apply it immediately # unlike the other functions so it doesn't overwrite what the modules load. env = EnvironmentModifications() # Remove these vars from the environment during build because they # can affect how some packages find libraries. We want to make # sure that builds never pull in unintended external dependencies. env.unset('LD_LIBRARY_PATH') env.unset('LIBRARY_PATH') env.unset('CPATH') env.unset('LD_RUN_PATH') env.unset('DYLD_LIBRARY_PATH') build_lang = spack.config.get('config:build_language') if build_lang: # Override language-related variables. This can be used to force # English compiler messages etc., which allows parse_log_events to # show useful matches. env.set('LC_ALL', build_lang) # Remove any macports installs from the PATH. The macports ld can # cause conflicts with the built-in linker on el capitan. Solves # assembler issues, e.g.: # suffix or operands invalid for `movq'" path = get_path('PATH') for p in path: if '/macports/' in p: env.remove_path('PATH', p) env.apply_modifications()
def clean_environment(): # Stuff in here sanitizes the build environment to eliminate # anything the user has set that may interfere. We apply it immediately # unlike the other functions so it doesn't overwrite what the modules load. env = EnvironmentModifications() # Remove these vars from the environment during build because they # can affect how some packages find libraries. We want to make # sure that builds never pull in unintended external dependencies. env.unset('LD_LIBRARY_PATH') env.unset('LIBRARY_PATH') env.unset('CPATH') env.unset('LD_RUN_PATH') env.unset('DYLD_LIBRARY_PATH') # Remove any macports installs from the PATH. The macports ld can # cause conflicts with the built-in linker on el capitan. Solves # assembler issues, e.g.: # suffix or operands invalid for `movq'" path = get_path('PATH') for p in path: if '/macports/' in p: env.remove_path('PATH', p) env.apply_modifications()