Skip to content

Commit

Permalink
add tomli as a dependency and adapt code to tomli>=2 (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt authored May 12, 2022
1 parent afb5a92 commit 182c2ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
18 changes: 7 additions & 11 deletions pyctdev/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
except ImportError:
setuptools_version = None

try:
import tomli as toml
except ImportError:
# tomllib added to the stdlib in Python 3.11
import tomllib as toml

toxconf = tox_config.parseconfig('tox')
# we later filter out any _onlytox commands...
toxconf_pre = configparser.ConfigParser()
Expand Down Expand Up @@ -246,19 +252,9 @@ def get_dependencies(groups,all_extras=False):


def get_buildreqs():
try:
import pip._vendor.pytoml as toml
except Exception:
try:
# pip>=20.1
import pip._vendor.toml as toml
except Exception:
# pip>=21.2.1
import pip._vendor.tomli as toml

buildreqs = []
if os.path.exists('pyproject.toml'):
with open('pyproject.toml') as f:
with open('pyproject.toml', 'rb') as f:
pp = toml.load(f)
if 'build-system' in pp:
buildreqs += pp['build-system'].get("requires",[])
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
# Pretty much part of every python distribution now anyway.
# Use it e.g. to be able to read pyproject.toml
# pinning to avoid https://github.com/pyviz/pyctdev/issues/12
'pip >=19.1.1'
'pip >=19.1.1',
# Added to no longer depend on tomli vendored by pip.
'tomli>=2;python_version<"3.11"',
],
extras_require={
'tests': ['flake8'],
Expand Down

0 comments on commit 182c2ac

Please sign in to comment.