|
1 | 1 | import subprocess |
2 | 2 | from distutils.errors import DistutilsPlatformError |
3 | | -from typing import Set, Union |
| 3 | +from typing import Optional, Set, Union |
4 | 4 |
|
5 | | -import semantic_version |
| 5 | +from semantic_version import Version |
6 | 6 | from typing_extensions import Literal |
7 | 7 |
|
8 | 8 | from .extension import Binding, RustExtension |
@@ -31,33 +31,12 @@ def binding_features( |
31 | 31 | raise DistutilsPlatformError(f"unknown Rust binding: '{ext.binding}'") |
32 | 32 |
|
33 | 33 |
|
34 | | -def get_rust_version(min_version=None): |
| 34 | +def get_rust_version() -> Optional[Version]: |
35 | 35 | try: |
36 | 36 | output = subprocess.check_output(["rustc", "-V"]).decode("latin-1") |
37 | | - return semantic_version.Version(output.split(" ")[1], partial=True) |
| 37 | + return Version(output.split(" ")[1]) |
38 | 38 | except (subprocess.CalledProcessError, OSError): |
39 | | - raise DistutilsPlatformError( |
40 | | - "can't find Rust compiler\n\n" |
41 | | - "If you are using an outdated pip version, it is possible a " |
42 | | - "prebuilt wheel is available for this package but pip is not able " |
43 | | - "to install from it. Installing from the wheel would avoid the " |
44 | | - "need for a Rust compiler.\n\n" |
45 | | - "To update pip, run:\n\n" |
46 | | - " pip install --upgrade pip\n\n" |
47 | | - "and then retry package installation.\n\n" |
48 | | - "If you did intend to build this package from source, try " |
49 | | - "installing a Rust compiler from your system package manager and " |
50 | | - "ensure it is on the PATH during installation. Alternatively, " |
51 | | - "rustup (available at https://rustup.rs) is the recommended way " |
52 | | - "to download and update the Rust compiler toolchain." |
53 | | - + ( |
54 | | - f"\n\nThis package requires Rust {min_version}." |
55 | | - if min_version is not None |
56 | | - else "" |
57 | | - ) |
58 | | - ) |
59 | | - except Exception as exc: |
60 | | - raise DistutilsPlatformError(f"can't get rustc version: {str(exc)}") |
| 39 | + return None |
61 | 40 |
|
62 | 41 |
|
63 | 42 | def get_rust_target_info(target_triple=None): |
|
0 commit comments