Skip to content

Commit a98e8a8

Browse files
committed
Try extra hard to pick up an existing tomli library from setuptools
Since setuptools-rust already depends on setuptools, it is reasonable to assume that even if tomli isn't installed, setuptools is. And setuptools includes a vendored copy of tomli. If the copy in setuptools has been devendored, it will be available via "tomli". If it isn't devendored, it will be available via "setuptools.extern.tomli" unless setuptools changes their vendoring approach which has lasted many years so far. Either way, we are sure to have a fallback tomli without explicitly depending on one, which means one less dependency to install in the common case.
1 parent 06d2360 commit a98e8a8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ classifiers = [
2626
dependencies = [
2727
"setuptools>=62.4",
2828
"semantic_version>=2.8.2,<3",
29-
'tomli>=1.2.1; python_version<"3.11"'
3029
]
3130

3231
[project.entry-points."distutils.commands"]

setuptools_rust/setuptools_ext.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@
2626
if sys.version_info[:2] >= (3, 11):
2727
from tomllib import load as toml_load
2828
else:
29-
from tomli import load as toml_load
29+
try:
30+
from tomli import load as toml_load
31+
except ImportError:
32+
from setuptools.extern.tomli import load as toml_load
3033

3134

3235
logger = logging.getLogger(__name__)

0 commit comments

Comments
 (0)