Skip to content

Commit

Permalink
Use tomllib/tomli over toml (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood committed May 1, 2023
1 parent 9641307 commit 0e745d2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions pyperformance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')):
Expand Down
8 changes: 6 additions & 2 deletions pyperformance/_pyproject_toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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():
Expand Down
10 changes: 3 additions & 7 deletions pyperformance/data-files/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pyperf

# for benchmark metadata:
packaging
toml
tomli; python_version < '3.11'


# Optional dependencies
Expand Down

0 comments on commit 0e745d2

Please sign in to comment.