diff options
author | Wouter Deconinck <wdconinc@gmail.com> | 2024-07-18 15:19:50 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-18 14:19:50 -0600 |
commit | ad1fc341993b32357a83e3c13861880187b535e7 (patch) | |
tree | ea30ddd9f61169856a5543c346d2aa7a55a7d643 | |
parent | ab723b25d0b0117978c654b7ed18b98e5f080ae8 (diff) | |
download | spack-ad1fc341993b32357a83e3c13861880187b535e7.tar.gz spack-ad1fc341993b32357a83e3c13861880187b535e7.tar.bz2 spack-ad1fc341993b32357a83e3c13861880187b535e7.tar.xz spack-ad1fc341993b32357a83e3c13861880187b535e7.zip |
rust: rework external find to require both rustc and cargo (#45286)
* rust: rework external find to require both rustc and cargo
* rust: handle unable to parse version
* [@spackbot] updating style on behalf of wdconinc
* rust: not x or not y -> not (x and y)
Co-authored-by: Alec Scott <hi@alecbcs.com>
* rust: pick first rustc found
Co-authored-by: Alec Scott <hi@alecbcs.com>
* rust: list comprehensions
Co-authored-by: Alec Scott <hi@alecbcs.com>
---------
Co-authored-by: wdconinc <wdconinc@users.noreply.github.com>
Co-authored-by: Alec Scott <hi@alecbcs.com>
-rw-r--r-- | var/spack/repos/builtin/packages/rust/package.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/var/spack/repos/builtin/packages/rust/package.py b/var/spack/repos/builtin/packages/rust/package.py index 81ab540ade..230d64ca05 100644 --- a/var/spack/repos/builtin/packages/rust/package.py +++ b/var/spack/repos/builtin/packages/rust/package.py @@ -103,10 +103,17 @@ class Rust(Package): phases = ["configure", "build", "install"] @classmethod - def determine_version(csl, exe): - output = Executable(exe)("--version", output=str, error=str) + def determine_spec_details(cls, prefix, exes_in_prefix): + rustc_candidates = [x for x in exes_in_prefix if os.path.basename(x) == "rustc"] + cargo_candidates = [x for x in exes_in_prefix if os.path.basename(x) == "cargo"] + # Both rustc and cargo must be present + if not (rustc_candidates and cargo_candidates): + return + output = Executable(rustc_candidates[0])("--version", output=str, error=str) match = re.match(r"rustc (\S+)", output) - return match.group(1) if match else None + if match: + version_str = match.group(1) + return Spec.from_detection(f"rust@{version_str}") def setup_dependent_package(self, module, dependent_spec): module.cargo = Executable(os.path.join(self.spec.prefix.bin, "cargo")) |