|
93 | 93 | from easybuild.tools.filetools import adjust_permissions, apply_patch, back_up_file, change_dir, check_lock
|
94 | 94 | from easybuild.tools.filetools import compute_checksum, convert_name, copy_dir, copy_file, create_lock
|
95 | 95 | from easybuild.tools.filetools import create_non_existing_paths, create_patch_info, derive_alt_pypi_url, diff_files
|
96 |
| -from easybuild.tools.filetools import dir_contains_files, download_file, encode_class_name, extract_file |
97 |
| -from easybuild.tools.filetools import find_backup_name_candidate, get_cwd, get_source_tarball_from_git, is_alt_pypi_url |
98 |
| -from easybuild.tools.filetools import is_binary, is_parent_path, is_sha256_checksum, mkdir, move_file, move_logs |
99 |
| -from easybuild.tools.filetools import read_file, remove_dir, remove_file, remove_lock, symlink, verify_checksum |
100 |
| -from easybuild.tools.filetools import weld_paths, write_file |
| 96 | +from easybuild.tools.filetools import download_file, encode_class_name, extract_file, find_backup_name_candidate |
| 97 | +from easybuild.tools.filetools import get_cwd, get_source_tarball_from_git, is_alt_pypi_url, is_binary, is_parent_path |
| 98 | +from easybuild.tools.filetools import is_sha256_checksum, mkdir, move_file, move_logs, read_file, remove_dir |
| 99 | +from easybuild.tools.filetools import remove_file, remove_lock, symlink, verify_checksum, weld_paths, write_file |
101 | 100 | from easybuild.tools.hooks import (
|
102 | 101 | BUILD_STEP, CLEANUP_STEP, CONFIGURE_STEP, EXTENSIONS_STEP, EXTRACT_STEP, FETCH_STEP, INSTALL_STEP, MODULE_STEP,
|
103 | 102 | MODULE_WRITE, PACKAGE_STEP, PATCH_STEP, PERMISSIONS_STEP, POSTITER_STEP, POSTPROC_STEP, PREPARE_STEP, READY_STEP,
|
@@ -1709,10 +1708,7 @@ def make_module_req(self):
|
1709 | 1708 | mod_req_paths = search_paths
|
1710 | 1709 | self.dry_run_msg(f" ${env_var}:{', '.join(mod_req_paths)}")
|
1711 | 1710 | else:
|
1712 |
| - mod_req_paths = [ |
1713 |
| - expanded_path for unexpanded_path in search_paths |
1714 |
| - for expanded_path in self.expand_module_search_path(unexpanded_path, path_type=search_paths.type) |
1715 |
| - ] |
| 1711 | + mod_req_paths = search_paths.expand_paths(self.installdir) |
1716 | 1712 |
|
1717 | 1713 | if mod_req_paths:
|
1718 | 1714 | mod_req_paths = nub(mod_req_paths) # remove duplicates
|
@@ -1786,64 +1782,10 @@ def inject_module_extra_paths(self):
|
1786 | 1782 |
|
1787 | 1783 | def expand_module_search_path(self, search_path, path_type=ModEnvVarType.PATH_WITH_FILES):
|
1788 | 1784 | """
|
1789 |
| - Expand given path glob and return list of suitable paths to be used as search paths: |
1790 |
| - - Paths must point to existing files/directories |
1791 |
| - - Relative paths are relative to installation prefix root and are kept relative after expansion |
1792 |
| - - Absolute paths are kept as absolute paths after expansion |
1793 |
| - - Follow symlinks and resolve their paths (avoids duplicate paths through symlinks) |
1794 |
| - - :path_type: ModEnvVarType that controls requirements for population of directories |
1795 |
| - - PATH: no requirements, can be empty |
1796 |
| - - PATH_WITH_FILES: must contain at least one file in them (default) |
1797 |
| - - PATH_WITH_TOP_FILES: increase stricness to require files in top level directory |
1798 |
| - """ |
1799 |
| - populated_path_types = ( |
1800 |
| - ModEnvVarType.PATH_WITH_FILES, |
1801 |
| - ModEnvVarType.PATH_WITH_TOP_FILES, |
1802 |
| - ModEnvVarType.STRICT_PATH_WITH_FILES, |
1803 |
| - ) |
1804 |
| - |
1805 |
| - if os.path.isabs(search_path): |
1806 |
| - abs_glob = search_path |
1807 |
| - else: |
1808 |
| - real_installdir = os.path.realpath(self.installdir) |
1809 |
| - abs_glob = os.path.join(real_installdir, search_path) |
1810 |
| - |
1811 |
| - exp_search_paths = glob.glob(abs_glob, recursive=True) |
1812 |
| - |
1813 |
| - retained_search_paths = [] |
1814 |
| - for abs_path in exp_search_paths: |
1815 |
| - # avoid going through symlink for strict path types |
1816 |
| - if path_type is ModEnvVarType.STRICT_PATH_WITH_FILES and abs_path != os.path.realpath(abs_path): |
1817 |
| - self.log.debug( |
1818 |
| - f"Discarded strict search path '{search_path} of type '{path_type}' that does not correspond " |
1819 |
| - f"to its real path: {abs_path}" |
1820 |
| - ) |
1821 |
| - continue |
1822 |
| - |
1823 |
| - if os.path.isdir(abs_path) and path_type in populated_path_types: |
1824 |
| - # only retain paths to directories that contain at least one file |
1825 |
| - recursive = path_type in (ModEnvVarType.PATH_WITH_FILES, ModEnvVarType.STRICT_PATH_WITH_FILES) |
1826 |
| - if not dir_contains_files(abs_path, recursive=recursive): |
1827 |
| - self.log.debug("Discarded search path to empty directory: %s", abs_path) |
1828 |
| - continue |
1829 |
| - |
1830 |
| - if os.path.isabs(search_path): |
1831 |
| - retain_path = abs_path |
1832 |
| - else: |
1833 |
| - # recover relative path |
1834 |
| - retain_path = os.path.relpath(os.path.realpath(abs_path), start=real_installdir) |
1835 |
| - if retain_path == '.': |
1836 |
| - retain_path = '' # use empty string to represent root of install dir |
1837 |
| - |
1838 |
| - if retain_path.startswith('..' + os.path.sep): |
1839 |
| - raise EasyBuildError( |
1840 |
| - f"Expansion of search path glob pattern '{search_path}' resulted in a relative path " |
1841 |
| - f"pointing outside of install directory: {retain_path}" |
1842 |
| - ) |
1843 |
| - |
1844 |
| - retained_search_paths.append(retain_path) |
1845 |
| - |
1846 |
| - return retained_search_paths |
| 1785 | + REMOVED in EasyBuild 5.1, use EasyBlock.module_load_environment.expand_paths instead |
| 1786 | + """ |
| 1787 | + msg = "expand_module_search_path is replaced by EasyBlock.module_load_environment.expand_paths" |
| 1788 | + self.log.nosupport(msg, '5.1') |
1847 | 1789 |
|
1848 | 1790 | def make_module_req_guess(self):
|
1849 | 1791 | """
|
|
0 commit comments