Voice et bot modif
This commit is contained in:
parent
189d56026b
commit
7333a22bcd
10774 changed files with 634644 additions and 933308 deletions
|
|
@ -1,18 +1,16 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
import os
|
||||
from collections import namedtuple
|
||||
from typing import Any
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from pip._vendor.packaging.requirements import InvalidRequirement
|
||||
from pip._vendor import tomli
|
||||
from pip._vendor.packaging.requirements import InvalidRequirement, Requirement
|
||||
|
||||
from pip._internal.exceptions import (
|
||||
InstallationError,
|
||||
InvalidPyProjectBuildRequires,
|
||||
MissingPyProjectBuildRequires,
|
||||
)
|
||||
from pip._internal.utils.compat import tomllib
|
||||
from pip._internal.utils.packaging import get_requirement
|
||||
|
||||
|
||||
def _is_list_of_str(obj: Any) -> bool:
|
||||
|
|
@ -29,11 +27,13 @@ BuildSystemDetails = namedtuple(
|
|||
|
||||
|
||||
def load_pyproject_toml(
|
||||
pyproject_toml: str, setup_py: str, req_name: str
|
||||
) -> BuildSystemDetails:
|
||||
use_pep517: Optional[bool], pyproject_toml: str, setup_py: str, req_name: str
|
||||
) -> Optional[BuildSystemDetails]:
|
||||
"""Load the pyproject.toml file.
|
||||
|
||||
Parameters:
|
||||
use_pep517 - Has the user requested PEP 517 processing? None
|
||||
means the user hasn't explicitly specified.
|
||||
pyproject_toml - Location of the project's pyproject.toml file
|
||||
setup_py - Location of the project's setup.py file
|
||||
req_name - The name of the requirement we're processing (for
|
||||
|
|
@ -61,12 +61,62 @@ def load_pyproject_toml(
|
|||
|
||||
if has_pyproject:
|
||||
with open(pyproject_toml, encoding="utf-8") as f:
|
||||
pp_toml = tomllib.loads(f.read())
|
||||
pp_toml = tomli.loads(f.read())
|
||||
build_system = pp_toml.get("build-system")
|
||||
else:
|
||||
build_system = None
|
||||
|
||||
# The following cases must use PEP 517
|
||||
# We check for use_pep517 being non-None and falsey because that means
|
||||
# the user explicitly requested --no-use-pep517. The value 0 as
|
||||
# opposed to False can occur when the value is provided via an
|
||||
# environment variable or config file option (due to the quirk of
|
||||
# strtobool() returning an integer in pip's configuration code).
|
||||
if has_pyproject and not has_setup:
|
||||
if use_pep517 is not None and not use_pep517:
|
||||
raise InstallationError(
|
||||
"Disabling PEP 517 processing is invalid: "
|
||||
"project does not have a setup.py"
|
||||
)
|
||||
use_pep517 = True
|
||||
elif build_system and "build-backend" in build_system:
|
||||
if use_pep517 is not None and not use_pep517:
|
||||
raise InstallationError(
|
||||
"Disabling PEP 517 processing is invalid: "
|
||||
"project specifies a build backend of {} "
|
||||
"in pyproject.toml".format(build_system["build-backend"])
|
||||
)
|
||||
use_pep517 = True
|
||||
|
||||
# If we haven't worked out whether to use PEP 517 yet,
|
||||
# and the user hasn't explicitly stated a preference,
|
||||
# we do so if the project has a pyproject.toml file
|
||||
# or if we cannot import setuptools or wheels.
|
||||
|
||||
# We fallback to PEP 517 when without setuptools or without the wheel package,
|
||||
# so setuptools can be installed as a default build backend.
|
||||
# For more info see:
|
||||
# https://discuss.python.org/t/pip-without-setuptools-could-the-experience-be-improved/11810/9
|
||||
# https://github.com/pypa/pip/issues/8559
|
||||
elif use_pep517 is None:
|
||||
use_pep517 = (
|
||||
has_pyproject
|
||||
or not importlib.util.find_spec("setuptools")
|
||||
or not importlib.util.find_spec("wheel")
|
||||
)
|
||||
|
||||
# At this point, we know whether we're going to use PEP 517.
|
||||
assert use_pep517 is not None
|
||||
|
||||
# If we're using the legacy code path, there is nothing further
|
||||
# for us to do here.
|
||||
if not use_pep517:
|
||||
return None
|
||||
|
||||
if build_system is None:
|
||||
# Either the user has a pyproject.toml with no build-system
|
||||
# section, or the user has no pyproject.toml, but has opted in
|
||||
# explicitly via --use-pep517.
|
||||
# In the absence of any explicit backend specification, we
|
||||
# assume the setuptools backend that most closely emulates the
|
||||
# traditional direct setup.py execution, and require wheel and
|
||||
|
|
@ -77,6 +127,12 @@ def load_pyproject_toml(
|
|||
"build-backend": "setuptools.build_meta:__legacy__",
|
||||
}
|
||||
|
||||
# If we're using PEP 517, we have build system information (either
|
||||
# from pyproject.toml, or defaulted by the code above).
|
||||
# Note that at this point, we do not know if the user has actually
|
||||
# specified a backend, though.
|
||||
assert build_system is not None
|
||||
|
||||
# Ensure that the build-system section in pyproject.toml conforms
|
||||
# to PEP 518.
|
||||
|
||||
|
|
@ -95,7 +151,7 @@ def load_pyproject_toml(
|
|||
# Each requirement must be valid as per PEP 508
|
||||
for requirement in requires:
|
||||
try:
|
||||
get_requirement(requirement)
|
||||
Requirement(requirement)
|
||||
except InvalidRequirement as error:
|
||||
raise InvalidPyProjectBuildRequires(
|
||||
package=req_name,
|
||||
|
|
@ -104,7 +160,7 @@ def load_pyproject_toml(
|
|||
|
||||
backend = build_system.get("build-backend")
|
||||
backend_path = build_system.get("backend-path", [])
|
||||
check: list[str] = []
|
||||
check: List[str] = []
|
||||
if backend is None:
|
||||
# If the user didn't specify a backend, we assume they want to use
|
||||
# the setuptools backend. But we can't be sure they have included
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue