Skip to content

Commit

Permalink
Merge pull request pypa#12797 from eli-schwartz/stdlib-tomllib
Browse files Browse the repository at this point in the history
Use the stdlib tomllib on python 3.11+
  • Loading branch information
sbidoul authored Jul 2, 2024
2 parents e238600 + 88c9f31 commit af719d8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions news/12797.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use tomllib from the stdlib if available, rather than tomli
9 changes: 7 additions & 2 deletions src/pip/_internal/pyproject.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import importlib.util
import os
import sys
from collections import namedtuple
from typing import Any, List, Optional

from pip._vendor import tomli
if sys.version_info >= (3, 11):
import tomllib
else:
from pip._vendor import tomli as tomllib

from pip._vendor.packaging.requirements import InvalidRequirement, Requirement

from pip._internal.exceptions import (
Expand Down Expand Up @@ -61,7 +66,7 @@ def load_pyproject_toml(

if has_pyproject:
with open(pyproject_toml, encoding="utf-8") as f:
pp_toml = tomli.loads(f.read())
pp_toml = tomllib.loads(f.read())
build_system = pp_toml.get("build-system")
else:
build_system = None
Expand Down
3 changes: 2 additions & 1 deletion src/pip/_vendor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def vendored(modulename):
vendored("rich.text")
vendored("rich.traceback")
vendored("tenacity")
vendored("tomli")
if sys.version_info < (3, 11):
vendored("tomli")
vendored("truststore")
vendored("urllib3")

0 comments on commit af719d8

Please sign in to comment.