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>
This commit is contained in:
		| @@ -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")) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Wouter Deconinck
					Wouter Deconinck