Skip to content

Commit 29c3e60

Browse files
authored
Merge pull request #4079 from joeydumont/source_url_cli_option
add support for `--extra-source-urls` to fetch sources from additional URLs
2 parents b966c5f + f5fcdb4 commit 29c3e60

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

easybuild/base/generaloption.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,16 @@ def what_str_list_tuple(name):
9797
"""Given name, return separator, class and helptext wrt separator.
9898
(Currently supports strlist, strtuple, pathlist, pathtuple)
9999
"""
100-
sep = ','
101-
helpsep = 'comma'
102100
if name.startswith('path'):
103101
sep = os.pathsep
104102
helpsep = 'pathsep'
103+
elif name.startswith('url'):
104+
# | is one of the only characters not in the grammar for URIs (RFC3986)
105+
sep = '|'
106+
helpsep = '|'
107+
else:
108+
sep = ','
109+
helpsep = 'comma'
105110

106111
klass = None
107112
if name.endswith('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: convert string seperated by '|' to 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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
from easybuild.tools.build_log import print_error, print_msg, print_warning
7373
from easybuild.tools.config import CHECKSUM_PRIORITY_JSON, DEFAULT_ENVVAR_USERS_MODULES
7474
from easybuild.tools.config import FORCE_DOWNLOAD_ALL, FORCE_DOWNLOAD_PATCHES, FORCE_DOWNLOAD_SOURCES
75+
from easybuild.tools.config import EASYBUILD_SOURCES_URL # noqa
7576
from easybuild.tools.config import build_option, build_path, get_log_filename, get_repository, get_repositorypath
7677
from easybuild.tools.config import install_path, log_path, package_path, source_paths
7778
from easybuild.tools.environment import restore_env, sanitize_env
@@ -105,9 +106,6 @@
105106
from easybuild.tools.utilities import remove_unwanted_chars, time2str, trace_msg
106107
from easybuild.tools.version import this_is_easybuild, VERBOSE_VERSION, VERSION
107108

108-
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,10 @@ 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 additional URLs as configured.
899+
for url in build_option("extra_source_urls"):
900+
url += "/" + name_letter + "/" + location
901+
source_urls.append(url)
902902

903903
mkdir(targetdir, parents=True)
904904

easybuild/tools/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@
120120
DEFAULT_PR_TARGET_ACCOUNT = 'easybuilders'
121121
DEFAULT_PREFIX = os.path.join(os.path.expanduser('~'), ".local", "easybuild")
122122
DEFAULT_REPOSITORY = 'FileRepository'
123+
EASYBUILD_SOURCES_URL = 'https://sources.easybuild.io'
124+
DEFAULT_EXTRA_SOURCE_URLS = (EASYBUILD_SOURCES_URL,)
123125
# Filter these CUDA libraries by default from the RPATH sanity check.
124126
# These are the only four libraries for which the CUDA toolkit ships stubs. By design, one is supposed to build
125127
# against the stub versions, but use the libraries that come with the CUDA driver at runtime. That means they should
@@ -393,6 +395,9 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
393395
'defaultopt': [
394396
'default_opt_level',
395397
],
398+
DEFAULT_EXTRA_SOURCE_URLS: [
399+
'extra_source_urls',
400+
],
396401
DEFAULT_ALLOW_LOADED_MODULES: [
397402
'allow_loaded_modules',
398403
],

easybuild/tools/options.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@
7070
from easybuild.tools.config import DEFAULT_JOB_EB_CMD, DEFAULT_LOGFILE_FORMAT, DEFAULT_MAX_FAIL_RATIO_PERMS
7171
from easybuild.tools.config import DEFAULT_MINIMAL_BUILD_ENV, DEFAULT_MNS, DEFAULT_MODULE_SYNTAX, DEFAULT_MODULES_TOOL
7272
from easybuild.tools.config import DEFAULT_MODULECLASSES, DEFAULT_PATH_SUBDIRS, DEFAULT_PKG_RELEASE, DEFAULT_PKG_TOOL
73-
from easybuild.tools.config import DEFAULT_PKG_TYPE, DEFAULT_PNS, DEFAULT_PREFIX, DEFAULT_PR_TARGET_ACCOUNT
73+
from easybuild.tools.config import DEFAULT_PKG_TYPE, DEFAULT_PNS, DEFAULT_PREFIX, DEFAULT_EXTRA_SOURCE_URLS
7474
from easybuild.tools.config import DEFAULT_REPOSITORY, DEFAULT_WAIT_ON_LOCK_INTERVAL, DEFAULT_WAIT_ON_LOCK_LIMIT
75-
from easybuild.tools.config import DEFAULT_FILTER_RPATH_SANITY_LIBS
75+
from easybuild.tools.config import DEFAULT_PR_TARGET_ACCOUNT, DEFAULT_FILTER_RPATH_SANITY_LIBS
7676
from easybuild.tools.config import EBROOT_ENV_VAR_ACTIONS, ERROR, FORCE_DOWNLOAD_CHOICES, GENERAL_CLASS, IGNORE
7777
from easybuild.tools.config import JOB_DEPS_TYPE_ABORT_ON_ERROR, JOB_DEPS_TYPE_ALWAYS_RUN, LOADED_MODULES_ACTIONS
7878
from easybuild.tools.config import LOCAL_VAR_NAMING_CHECK_WARN, LOCAL_VAR_NAMING_CHECKS
@@ -408,6 +408,8 @@ def override_options(self):
408408
None, 'store_true', False),
409409
'extra-modules': ("List of extra modules to load after setting up the build environment",
410410
'strlist', 'extend', None),
411+
"extra-source-urls": ("Specify URLs to fetch sources from in addition to those in the easyconfig",
412+
"urltuple", "add_flex", DEFAULT_EXTRA_SOURCE_URLS, {'metavar': 'URL[|URL]'}),
411413
'fetch': ("Allow downloading sources ignoring OS and modules tool dependencies, "
412414
"implies --stop=fetch, --ignore-osdeps and ignore modules tool", None, 'store_true', False),
413415
'filter-deps': ("List of dependencies that you do *not* want to install with EasyBuild, "

0 commit comments

Comments
 (0)