Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ classifiers = [
dependencies = [
"setuptools>=62.4",
"semantic_version>=2.8.2,<3",
'tomli>=1.2.1; python_version<"3.11"'
]

[project.entry-points."distutils.commands"]
Expand Down
7 changes: 6 additions & 1 deletion setuptools_rust/extension.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import json
import os
import re
Expand All @@ -14,11 +16,13 @@
NewType,
Optional,
Sequence,
TYPE_CHECKING,
Union,
cast,
)

from semantic_version import SimpleSpec
if TYPE_CHECKING:
from semantic_version import SimpleSpec

from ._utils import format_called_process_error

Expand Down Expand Up @@ -185,6 +189,7 @@ def get_rust_version(self) -> Optional[SimpleSpec]: # type: ignore[no-any-unimp
if self.rust_version is None:
return None
try:
from semantic_version import SimpleSpec
return SimpleSpec(self.rust_version)
except ValueError:
raise SetupError(
Expand Down
8 changes: 6 additions & 2 deletions setuptools_rust/rustc_info.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
from __future__ import annotations

import subprocess
from setuptools.errors import PlatformError
from functools import lru_cache
from typing import Dict, List, NewType, Optional
from typing import Dict, List, NewType, Optional, TYPE_CHECKING

from semantic_version import Version
if TYPE_CHECKING:
from semantic_version import Version


def get_rust_version() -> Optional[Version]: # type: ignore[no-any-unimported]
try:
# first line of rustc -Vv is something like
# rustc 1.61.0 (fe5b13d68 2022-05-18)
from semantic_version import Version
return Version(_rust_version().split(" ")[1])
except (subprocess.CalledProcessError, OSError):
return None
Expand Down
5 changes: 4 additions & 1 deletion setuptools_rust/setuptools_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
if sys.version_info[:2] >= (3, 11):
from tomllib import load as toml_load
else:
from tomli import load as toml_load
try:
from tomli import load as toml_load
except ImportError:
from setuptools.extern.tomli import load as toml_load
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting; I wasn't aware of this namespace and have just asked upstream at pypa/setuptools#4351 (comment)



logger = logging.getLogger(__name__)
Expand Down