MCPcopy Create free account
hub / github.com/PyO3/setuptools-rust / run

Method run

setuptools_rust/command.py:49–115  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

47 self.extensions = extensions
48
49 def run(self) -> None:
50 if not self.extensions:
51 logger.info("%s: no rust_extensions defined", self.get_command_name())
52 return
53
54 all_optional = all(ext.optional for ext in self.extensions)
55 # Use the environment of the first non-optional extension, or the first optional
56 # extension if there is no non-optional extension.
57 env = None
58 for ext in self.extensions:
59 if ext.env:
60 env = ext.env
61 if not ext.optional:
62 break
63 try:
64 version = get_rust_version(env)
65 if version is None:
66 min_version = max( # type: ignore[type-var]
67 filter(
68 lambda version: version is not None,
69 (ext.get_rust_version() for ext in self.extensions),
70 ),
71 default=None,
72 )
73 raise PlatformError(
74 "can't find Rust compiler\n\n"
75 "If you are using an outdated pip version, it is possible a "
76 "prebuilt wheel is available for this package but pip is not able "
77 "to install from it. Installing from the wheel would avoid the "
78 "need for a Rust compiler.\n\n"
79 "To update pip, run:\n\n"
80 " pip install --upgrade pip\n\n"
81 "and then retry package installation.\n\n"
82 "If you did intend to build this package from source, try "
83 "installing a Rust compiler from your system package manager and "
84 "ensure it is on the PATH during installation. Alternatively, "
85 "rustup (available at https://rustup.rs) is the recommended way "
86 "to download and update the Rust compiler toolchain."
87 + (
88 f"\n\nThis package requires Rust {min_version}."
89 if min_version is not None
90 else ""
91 )
92 )
93 except PlatformError as e:
94 if not all_optional:
95 raise
96 else:
97 print(str(e))
98 return
99
100 for ext in self.extensions:
101 try:
102 rust_version = ext.get_rust_version()
103 if rust_version is not None and version not in rust_version:
104 raise PlatformError(
105 f"Rust {version} does not match extension requirement {rust_version}"
106 )

Callers 15

test_examplesFunction · 0.45
test_sdist_vendorFunction · 0.45
test_crossenvFunction · 0.45
test_crossFunction · 0.45
ruffFunction · 0.45
mypyFunction · 0.45
testFunction · 0.45
test_examples_emscriptenFunction · 0.45
bump_versionFunction · 0.45
docsFunction · 0.45
run_subprocessFunction · 0.45

Calls 3

run_for_extensionMethod · 0.95
get_rust_versionFunction · 0.85
get_rust_versionMethod · 0.80

Tested by 6

test_examplesFunction · 0.36
test_sdist_vendorFunction · 0.36
test_crossenvFunction · 0.36
test_crossFunction · 0.36
test_examples_emscriptenFunction · 0.36
test_inplaceFunction · 0.36