Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit 182c2ac

Browse files
authored
add tomli as a dependency and adapt code to tomli>=2 (#93)
1 parent afb5a92 commit 182c2ac

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

pyctdev/util.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
except ImportError:
2222
setuptools_version = None
2323

24+
try:
25+
import tomli as toml
26+
except ImportError:
27+
# tomllib added to the stdlib in Python 3.11
28+
import tomllib as toml
29+
2430
toxconf = tox_config.parseconfig('tox')
2531
# we later filter out any _onlytox commands...
2632
toxconf_pre = configparser.ConfigParser()
@@ -246,19 +252,9 @@ def get_dependencies(groups,all_extras=False):
246252

247253

248254
def get_buildreqs():
249-
try:
250-
import pip._vendor.pytoml as toml
251-
except Exception:
252-
try:
253-
# pip>=20.1
254-
import pip._vendor.toml as toml
255-
except Exception:
256-
# pip>=21.2.1
257-
import pip._vendor.tomli as toml
258-
259255
buildreqs = []
260256
if os.path.exists('pyproject.toml'):
261-
with open('pyproject.toml') as f:
257+
with open('pyproject.toml', 'rb') as f:
262258
pp = toml.load(f)
263259
if 'build-system' in pp:
264260
buildreqs += pp['build-system'].get("requires",[])

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
# Pretty much part of every python distribution now anyway.
4444
# Use it e.g. to be able to read pyproject.toml
4545
# pinning to avoid https://github.com/pyviz/pyctdev/issues/12
46-
'pip >=19.1.1'
46+
'pip >=19.1.1',
47+
# Added to no longer depend on tomli vendored by pip.
48+
'tomli>=2;python_version<"3.11"',
4749
],
4850
extras_require={
4951
'tests': ['flake8'],

0 commit comments

Comments
 (0)