Skip to content

Commit e9c8f7b

Browse files
joeydumontFlamefire
andcommitted
Add an --extra-source-urls CLI option to fetch sources from additional URLs.
Add the --extra-source-urls CLI option, a | separated list of URLs that EasyBuild will fetch sources from. It replaces the hard-coded EASYBUILD_SOURCES_URL, but keeps it as a default value. Uses the add_flex logic to prepend, append, or insert into the default list. Co-authored-by: Alexander Grund <[email protected]>
1 parent 1148625 commit e9c8f7b

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

easybuild/base/generaloption.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ def what_str_list_tuple(name):
103103
sep = os.pathsep
104104
helpsep = 'pathsep'
105105

106+
elif name.startswith('url'):
107+
# | is one of the only characters not in the grammar for URIs (RFC3986)
108+
sep = '|'
109+
helpsep = '|'
110+
106111
klass = None
107112
if name.endswith('list'):
108113
klass = list
@@ -182,6 +187,7 @@ class ExtOption(CompleterOption):
182187
- strlist, strtuple : convert comma-separated string in a list resp. tuple of strings
183188
- pathlist, pathtuple : using os.pathsep, convert pathsep-separated string in a list resp. tuple of strings
184189
- the path separator is OS-dependent
190+
- urllist, urltuple: using '|', convert urlsep separated string in a list resp. tuple of strings
185191
"""
186192
EXTEND_SEPARATOR = ','
187193

@@ -198,7 +204,7 @@ class ExtOption(CompleterOption):
198204
TYPED_ACTIONS = Option.TYPED_ACTIONS + EXTOPTION_EXTRA_OPTIONS + EXTOPTION_STORE_OR
199205
ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + EXTOPTION_EXTRA_OPTIONS
200206

201-
TYPE_STRLIST = ['%s%s' % (name, klass) for klass in ['list', 'tuple'] for name in ['str', 'path']]
207+
TYPE_STRLIST = ['%s%s' % (name, klass) for klass in ['list', 'tuple'] for name in ['str', 'path', 'url']]
202208
TYPE_CHECKER = {x: check_str_list_tuple for x in TYPE_STRLIST}
203209
TYPE_CHECKER.update(Option.TYPE_CHECKER)
204210
TYPES = tuple(TYPE_STRLIST + list(Option.TYPES))

easybuild/framework/easyblock.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@
106106
from easybuild.tools.version import this_is_easybuild, VERBOSE_VERSION, VERSION
107107

108108

109-
EASYBUILD_SOURCES_URL = 'https://sources.easybuild.io'
110-
111109
DEFAULT_BIN_LIB_SUBDIRS = ('bin', 'lib', 'lib64')
112110

113111
MODULE_ONLY_STEPS = [MODULE_STEP, PREPARE_STEP, READY_STEP, POSTITER_STEP, SANITYCHECK_STEP]
@@ -897,8 +895,13 @@ def obtain_file(self, filename, extension=False, urls=None, download_filename=No
897895
source_urls = []
898896
source_urls.extend(self.cfg['source_urls'])
899897

900-
# add https://sources.easybuild.io as fallback source URL
901-
source_urls.append(EASYBUILD_SOURCES_URL + '/' + os.path.join(name_letter, location))
898+
# add extra-source-urls CLI as either a first check, or a fallback.
899+
self.log.warning("[extra_source_urls] %s", build_option('extra_source_urls'))
900+
for url in build_option("extra_source_urls"):
901+
url += "/" + name_letter + "/" + location
902+
self.log.warning("[extra_source_urls] url is %s", url)
903+
source_urls.extend([url])
904+
self.log.warning("[extra_source_urls] %s", source_urls)
902905

903906
mkdir(targetdir, parents=True)
904907

easybuild/tools/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
DEFAULT_PR_TARGET_ACCOUNT = 'easybuilders'
121121
DEFAULT_PREFIX = os.path.join(os.path.expanduser('~'), ".local", "easybuild")
122122
DEFAULT_REPOSITORY = 'FileRepository'
123+
DEFAULT_EXTRA_SOURCE_URLS = ('https://sources.easybuild.io/',)
123124
# Filter these CUDA libraries by default from the RPATH sanity check.
124125
# These are the only four libraries for which the CUDA toolkit ships stubs. By design, one is supposed to build
125126
# against the stub versions, but use the libraries that come with the CUDA driver at runtime. That means they should
@@ -215,6 +216,7 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
215216
'easyblock',
216217
'envvars_user_modules',
217218
'extra_modules',
219+
'extra_source_urls',
218220
'filter_deps',
219221
'filter_ecs',
220222
'filter_env_vars',

easybuild/tools/options.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,12 @@
6969
from easybuild.tools.config import DEFAULT_JOB_EB_CMD, DEFAULT_LOGFILE_FORMAT, DEFAULT_MAX_FAIL_RATIO_PERMS
7070
from easybuild.tools.config import DEFAULT_MINIMAL_BUILD_ENV, DEFAULT_MNS, DEFAULT_MODULE_SYNTAX, DEFAULT_MODULES_TOOL
7171
from easybuild.tools.config import DEFAULT_MODULECLASSES, DEFAULT_PATH_SUBDIRS, DEFAULT_PKG_RELEASE, DEFAULT_PKG_TOOL
72-
from easybuild.tools.config import DEFAULT_PKG_TYPE, DEFAULT_PNS, DEFAULT_PREFIX, DEFAULT_PR_TARGET_ACCOUNT
72+
from easybuild.tools.config import DEFAULT_PKG_TYPE, DEFAULT_PNS, DEFAULT_PREFIX, DEFAULT_EXTRA_SOURCE_URLS
73+
from easybuild.tools.config import DEFAULT_PR_TARGET_ACCOUNT
7374
from easybuild.tools.config import DEFAULT_REPOSITORY, DEFAULT_WAIT_ON_LOCK_INTERVAL, DEFAULT_WAIT_ON_LOCK_LIMIT
7475
from easybuild.tools.config import DEFAULT_FILTER_RPATH_SANITY_LIBS
75-
from easybuild.tools.config import EBROOT_ENV_VAR_ACTIONS, ERROR, FORCE_DOWNLOAD_CHOICES, GENERAL_CLASS, IGNORE
76+
from easybuild.tools.config import EBROOT_ENV_VAR_ACTIONS, ERROR
77+
from easybuild.tools.config import FORCE_DOWNLOAD_CHOICES, GENERAL_CLASS, IGNORE
7678
from easybuild.tools.config import JOB_DEPS_TYPE_ABORT_ON_ERROR, JOB_DEPS_TYPE_ALWAYS_RUN, LOADED_MODULES_ACTIONS
7779
from easybuild.tools.config import LOCAL_VAR_NAMING_CHECK_WARN, LOCAL_VAR_NAMING_CHECKS
7880
from easybuild.tools.config import OUTPUT_STYLE_AUTO, OUTPUT_STYLES, WARN
@@ -407,6 +409,8 @@ def override_options(self):
407409
None, 'store_true', False),
408410
'extra-modules': ("List of extra modules to load after setting up the build environment",
409411
'strlist', 'extend', None),
412+
"extra-source-urls": ("Specify URLs to fetch sources from in addition to those in the easyconfig",
413+
"urltuple", "add_flex", DEFAULT_EXTRA_SOURCE_URLS, {'metavar': 'URL[%sURL]' % '|'}),
410414
'fetch': ("Allow downloading sources ignoring OS and modules tool dependencies, "
411415
"implies --stop=fetch, --ignore-osdeps and ignore modules tool", None, 'store_true', False),
412416
'filter-deps': ("List of dependencies that you do *not* want to install with EasyBuild, "

0 commit comments

Comments
 (0)