29def load_pyproject_toml(
30 use_pep517: Optional[bool], pyproject_toml: str, setup_py: str, req_name: str
31) -> Optional[BuildSystemDetails]:
32 """Load the pyproject.toml file.
35 use_pep517 - Has the user requested PEP 517 processing? None
36 means the user hasn't explicitly specified.
37 pyproject_toml - Location of the project's pyproject.toml file
38 setup_py - Location of the project's setup.py file
39 req_name - The name of the requirement we're processing (for
43 None if we should use the legacy code path, otherwise a tuple
45 requirements from pyproject.toml,
46 name of PEP 517 backend,
47 requirements we should check are installed after setting
48 up the build environment
49 directory paths to import the backend from (backend-path),
50 relative to the project root.
56 if not has_pyproject
and not has_setup:
58 f
"{req_name} does not appear to be a Python project: "
59 f
"neither 'setup.py' nor 'pyproject.toml' found."
63 with open(pyproject_toml, encoding=
"utf-8")
as f:
75 if has_pyproject
and not has_setup:
76 if use_pep517
is not None and not use_pep517:
78 "Disabling PEP 517 processing is invalid: "
79 "project does not have a setup.py"
82 elif build_system
and "build-backend" in build_system:
83 if use_pep517
is not None and not use_pep517:
85 "Disabling PEP 517 processing is invalid: "
86 "project specifies a build backend of {} "
87 "in pyproject.toml".format(build_system[
"build-backend"])
101 elif use_pep517
is None:
109 assert use_pep517
is not None
116 if build_system
is None:
126 "requires": [
"setuptools>=40.8.0",
"wheel"],
127 "build-backend":
"setuptools.build_meta:__legacy__",
134 assert build_system
is not None
140 if "requires" not in build_system:
144 requires = build_system[
"requires"]
148 reason=
"It is not a list of strings.",
152 for requirement
in requires:
155 except InvalidRequirement
as error:
158 reason=f
"It contains an invalid requirement: {requirement!r}",
163 check: List[str] = []
176 backend =
"setuptools.build_meta:__legacy__"
177 check = [
"setuptools>=40.8.0"]