Skip to content

Commit c56b79d

Browse files
committed
deps: update semantic_version
1 parent c1813ac commit c56b79d

File tree

5 files changed

+35
-34
lines changed

5 files changed

+35
-34
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
- Add new default `"auto"` setting for `RustExtension.py_limited_api`. [#137](https://github.com/PyO3/setuptools-rust/pull/137)
77
- Support very verbose cargo build.rs output. [#140](https://github.com/PyO3/setuptools-rust/pull/140)
88

9+
### Changed
10+
- Switch to `tomli` dependency. [#174](https://github.com/PyO3/setuptools-rust/pull/174)
11+
912
### Removed
1013
- Remove `test_rust` command. (`python setup.py test` is deprecated.) [#129](https://github.com/PyO3/setuptools-rust/pull/129)
1114
- Remove `check_rust` command. [#131](https://github.com/PyO3/setuptools-rust/pull/131)

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ classifiers =
2626
[options]
2727
packages = setuptools_rust
2828
zip_safe = True
29-
install_requires = setuptools>=46.1; semantic_version>=2.6.0; tomli>=1.2.1; typing_extensions>=3.7.4.3
29+
install_requires = setuptools>=46.1; semantic_version>=2.8.2,<3; tomli>=1.2.1; typing_extensions>=3.7.4.3
3030
setup_requires = setuptools>=46.1; setuptools_scm>=6.3.2
3131
python_requires = >=3.6
3232

setuptools_rust/command.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from abc import ABC, abstractmethod
2-
32
from distutils.cmd import Command
43
from distutils.errors import DistutilsPlatformError
54

@@ -26,15 +25,35 @@ def run(self):
2625

2726
all_optional = all(ext.optional for ext in self.extensions)
2827
try:
29-
version = get_rust_version(
30-
min_version=max(
28+
version = get_rust_version()
29+
if version is None:
30+
min_version = max(
3131
filter(
3232
lambda version: version is not None,
3333
(ext.get_rust_version() for ext in self.extensions),
3434
),
3535
default=None,
3636
)
37-
)
37+
raise DistutilsPlatformError(
38+
"can't find Rust compiler\n\n"
39+
"If you are using an outdated pip version, it is possible a "
40+
"prebuilt wheel is available for this package but pip is not able "
41+
"to install from it. Installing from the wheel would avoid the "
42+
"need for a Rust compiler.\n\n"
43+
"To update pip, run:\n\n"
44+
" pip install --upgrade pip\n\n"
45+
"and then retry package installation.\n\n"
46+
"If you did intend to build this package from source, try "
47+
"installing a Rust compiler from your system package manager and "
48+
"ensure it is on the PATH during installation. Alternatively, "
49+
"rustup (available at https://rustup.rs) is the recommended way "
50+
"to download and update the Rust compiler toolchain."
51+
+ (
52+
f"\n\nThis package requires Rust {min_version}."
53+
if min_version is not None
54+
else ""
55+
)
56+
)
3857
except DistutilsPlatformError as e:
3958
if not all_optional:
4059
raise

setuptools_rust/extension.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from enum import IntEnum, auto
55
from typing import Dict, List, Optional, Union
66

7-
import semantic_version
87
import tomli
8+
from semantic_version import SimpleSpec
99
from typing_extensions import Literal
1010

1111

@@ -160,11 +160,11 @@ def get_lib_name(self):
160160
name = re.sub(r"[./\\-]", "_", name)
161161
return name
162162

163-
def get_rust_version(self):
163+
def get_rust_version(self) -> Optional[SimpleSpec]:
164164
if self.rust_version is None:
165165
return None
166166
try:
167-
return semantic_version.SimpleSpec.parse(self.rust_version)
167+
return SimpleSpec(self.rust_version)
168168
except ValueError:
169169
raise DistutilsSetupError(
170170
"Can not parse rust compiler version: %s", self.rust_version

setuptools_rust/utils.py

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import subprocess
22
from distutils.errors import DistutilsPlatformError
3-
from typing import Set, Union
3+
from typing import Optional, Set, Union
44

5-
import semantic_version
5+
from semantic_version import Version
66
from typing_extensions import Literal
77

88
from .extension import Binding, RustExtension
@@ -31,33 +31,12 @@ def binding_features(
3131
raise DistutilsPlatformError(f"unknown Rust binding: '{ext.binding}'")
3232

3333

34-
def get_rust_version(min_version=None):
34+
def get_rust_version() -> Optional[Version]:
3535
try:
3636
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])
3838
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
6140

6241

6342
def get_rust_target_info(target_triple=None):

0 commit comments

Comments
 (0)