Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 29 additions & 21 deletions easybuild/easyblocks/generic/cargo.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,30 +214,38 @@ def __init__(self, *args, **kwargs):
self.cargo_home = os.path.join(self.builddir, '.cargo')
self.set_cargo_vars()

# Populate sources from "crates" list of tuples
sources = []
for crate_info in self.crates:
if len(crate_info) == 2:
sources.append({
'download_filename': self.crate_download_filename(*crate_info),
'filename': self.crate_src_filename(*crate_info),
'source_urls': [CRATESIO_SOURCE],
'alt_location': 'crates.io',
})
else:
crate, version, repo, rev = crate_info
url, repo_name = repo.rsplit('/', maxsplit=1)
if repo_name.endswith('.git'):
repo_name = repo_name[:-4]
sources.append({
'git_config': {'url': url, 'repo_name': repo_name, 'commit': rev},
'filename': self.crate_src_filename(crate, version, rev=rev),
})

# copy EasyConfig instance before we make changes to it
self.cfg = self.cfg.copy()

self.cfg.update('sources', sources)
if self.is_extension:
self.cfg['crates'] = self.options.get('crates', []) # Don't inherit crates from parent
# The (regular) extract step for extensions is not run so our handling of crates as (multiple) sources
# cannot be used for extensions.
if self.crates:
raise EasyBuildError(f"Extension '{self.name}' cannot have crates. "
"You can add them to the top-level config parameters when using e.g."
"the Cargo or CargoPythonBundle easyblock.")
else:
# Populate sources from "crates" list of tuples
sources = []
for crate_info in self.crates:
if len(crate_info) == 2:
sources.append({
'download_filename': self.crate_download_filename(*crate_info),
'filename': self.crate_src_filename(*crate_info),
'source_urls': [CRATESIO_SOURCE],
'alt_location': 'crates.io',
})
else:
crate, version, repo, rev = crate_info
url, repo_name = repo.rsplit('/', maxsplit=1)
if repo_name.endswith('.git'):
repo_name = repo_name[:-4]
sources.append({
'git_config': {'url': url, 'repo_name': repo_name, 'commit': rev},
'filename': self.crate_src_filename(crate, version, rev=rev),
})
self.cfg.update('sources', sources)

def set_cargo_vars(self):
"""Set environment variables for Rust compilation and Cargo"""
Expand Down
2 changes: 2 additions & 0 deletions easybuild/easyblocks/generic/cargopythonbundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ def extra_options(extra_vars=None):
"""Define extra easyconfig parameters specific to Cargo"""
extra_vars = PythonBundle.extra_options(extra_vars)
extra_vars = Cargo.extra_options(extra_vars) # not all extra options here will used here
extra_vars['default_easyblock'][0] = 'CargoPythonPackage'

return extra_vars

def __init__(self, *args, **kwargs):
"""Constructor for CargoPythonBundle easyblock."""
self.check_for_sources = False # make Bundle allow sources (as crates are treated as sources)
super().__init__(*args, **kwargs)
self.cfg['exts_defaultclass'] = 'CargoPythonPackage'

# Cargo inherits from ExtensionEasyBlock, thus EB treats the software itself as an extension
# Setting modulename to False to ensure that sanity checks are performed on the extensions only
Expand Down