Skip to content

Commit 04d30c2

Browse files
committed
Merge branch '20251118151816_new_pr_cargopythonbundle' into 20251121090749_new_pr_cargo
2 parents 27bf1ef + 4afa9fb commit 04d30c2

File tree

2 files changed

+31
-21
lines changed

2 files changed

+31
-21
lines changed

easybuild/easyblocks/generic/cargo.py

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -225,30 +225,38 @@ def __init__(self, *args, **kwargs):
225225
self.cargo_home = os.path.join(self.builddir, '.cargo')
226226
self.set_cargo_vars()
227227

228-
# Populate sources from "crates" list of tuples
229-
sources = []
230-
for crate_info in self.crates:
231-
if len(crate_info) == 2:
232-
sources.append({
233-
'download_filename': self.crate_download_filename(*crate_info),
234-
'filename': self.crate_src_filename(*crate_info),
235-
'source_urls': [CRATESIO_SOURCE],
236-
'alt_location': 'crates.io',
237-
})
238-
else:
239-
crate, version, repo, rev = crate_info
240-
url, repo_name = repo.rsplit('/', maxsplit=1)
241-
if repo_name.endswith('.git'):
242-
repo_name = repo_name[:-4]
243-
sources.append({
244-
'git_config': {'url': url, 'repo_name': repo_name, 'commit': rev},
245-
'filename': self.crate_src_filename(crate, version, rev=rev),
246-
})
247-
248228
# copy EasyConfig instance before we make changes to it
249229
self.cfg = self.cfg.copy()
250230

251-
self.cfg.update('sources', sources)
231+
if self.is_extension:
232+
self.cfg['crates'] = self.options.get('crates', []) # Don't inherit crates from parent
233+
# The (regular) extract step for extensions is not run so our handling of crates as (multiple) sources
234+
# cannot be used for extensions.
235+
if self.crates:
236+
raise EasyBuildError(f"Extension '{self.name}' cannot have crates. "
237+
"You can add them to the top-level config parameters when using e.g."
238+
"the Cargo or CargoPythonBundle easyblock.")
239+
else:
240+
# Populate sources from "crates" list of tuples
241+
sources = []
242+
for crate_info in self.crates:
243+
if len(crate_info) == 2:
244+
sources.append({
245+
'download_filename': self.crate_download_filename(*crate_info),
246+
'filename': self.crate_src_filename(*crate_info),
247+
'source_urls': [CRATESIO_SOURCE],
248+
'alt_location': 'crates.io',
249+
})
250+
else:
251+
crate, version, repo, rev = crate_info
252+
url, repo_name = repo.rsplit('/', maxsplit=1)
253+
if repo_name.endswith('.git'):
254+
repo_name = repo_name[:-4]
255+
sources.append({
256+
'git_config': {'url': url, 'repo_name': repo_name, 'commit': rev},
257+
'filename': self.crate_src_filename(crate, version, rev=rev),
258+
})
259+
self.cfg.update('sources', sources)
252260

253261
def set_cargo_vars(self):
254262
"""Set environment variables for Rust compilation and Cargo"""

easybuild/easyblocks/generic/cargopythonbundle.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ def extra_options(extra_vars=None):
4545
"""Define extra easyconfig parameters specific to Cargo"""
4646
extra_vars = PythonBundle.extra_options(extra_vars)
4747
extra_vars = Cargo.extra_options(extra_vars) # not all extra options here will used here
48+
extra_vars['default_easyblock'][0] = 'CargoPythonPackage'
4849

4950
return extra_vars
5051

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

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

0 commit comments

Comments
 (0)