Skip to content

Commit

Permalink
Merge pull request #3404 from Flamefire/cargocrash
Browse files Browse the repository at this point in the history
fix crash in Cargo easyblock when no crates are specified
  • Loading branch information
Micket authored Aug 30, 2024
2 parents b0b012e + a9cadc4 commit cc5b95d
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions easybuild/easyblocks/generic/cargo.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,34 +131,32 @@ def __init__(self, *args, **kwargs):
env.setvar('RUST_LOG', 'DEBUG')
env.setvar('RUST_BACKTRACE', '1')

# Populate sources from "crates" list of tuples (only once)
if self.cfg['crates']:
# Move 'crates' list from easyconfig parameter to property,
# to avoid that creates are processed into 'sources' easyconfig parameter again
# when easyblock is initialized again using the same parsed easyconfig
# (for example when check_sha256_checksums function is called, like in easyconfigs test suite)
self.crates = self.cfg['crates']
self.cfg['crates'] = []
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),
})

self.cfg.update('sources', sources)
# 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),
})

self.cfg.update('sources', sources)

@property
def crates(self):
"""Return the crates as defined in the EasyConfig"""
return self.cfg['crates']

def extract_step(self):
"""
Expand Down

0 comments on commit cc5b95d

Please sign in to comment.