diff --git a/pyperformance/__init__.py b/pyperformance/__init__.py index 647d1072..7248ce02 100644 --- a/pyperformance/__init__.py +++ b/pyperformance/__init__.py @@ -34,10 +34,10 @@ def _is_devel_install(): # This means it creates a link back to the checkout instead # of copying the files. try: - import toml + import packaging except ModuleNotFoundError: return False - sitepackages = os.path.dirname(os.path.dirname(toml.__file__)) + sitepackages = os.path.dirname(os.path.dirname(packaging.__file__)) if os.path.isdir(os.path.join(sitepackages, 'pyperformance')): return False if not os.path.exists(os.path.join(sitepackages, 'pyperformance.egg-link')): diff --git a/pyperformance/_pyproject_toml.py b/pyperformance/_pyproject_toml.py index e7c6563c..ab6f6f85 100644 --- a/pyperformance/_pyproject_toml.py +++ b/pyperformance/_pyproject_toml.py @@ -18,7 +18,11 @@ import packaging.specifiers import packaging.utils import packaging.version -import toml + +try: + import tomllib +except ImportError: + import tomli as tomllib from ._utils import check_name @@ -52,7 +56,7 @@ def parse_pyproject_toml(text, rootdir, name=None, *, tools=None, requirefiles=True, ): - data = toml.loads(text) + data = tomllib.loads(text) unused = list(data) for section, normalize in SECTIONS.items(): diff --git a/pyperformance/data-files/requirements.txt b/pyperformance/data-files/requirements.txt index 9c1bbf8f..4da6b34e 100644 --- a/pyperformance/data-files/requirements.txt +++ b/pyperformance/data-files/requirements.txt @@ -2,17 +2,13 @@ # This file is autogenerated by pip-compile with Python 3.11 # by the following command: # -# pip-compile --output-file=requirements.txt requirements.in +# pip-compile --output-file=pyperformance/data-files/requirements.txt requirements.in # -packaging==21.3 +packaging==23.1 # via -r requirements.in -psutil==5.9.0 +psutil==5.9.5 # via # -r requirements.in # pyperf -pyparsing==3.0.8 - # via packaging pyperf==2.6.0 # via -r requirements.in -toml==0.10.2 - # via -r requirements.in diff --git a/pyproject.toml b/pyproject.toml index f69c39c4..369ea0b9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,11 @@ classifiers = [ 'Programming Language :: Python', ] requires-python = ">=3.7" -dependencies = ["pyperf", "toml", "packaging"] +dependencies = [ + "pyperf", + "tomli; python_version < '3.11'", + "packaging", +] [project.optional-dependencies] dev = [ diff --git a/requirements.in b/requirements.in index 0d76bbd8..55f432ef 100644 --- a/requirements.in +++ b/requirements.in @@ -13,7 +13,7 @@ pyperf # for benchmark metadata: packaging -toml +tomli; python_version < '3.11' # Optional dependencies