Don't warn if pyproject.toml does not contain build-system.requires

This commit is contained in:
Pradyun Gedam 2018-07-21 12:58:27 +05:30
parent 67c5155476
commit c18f19a6a4
No known key found for this signature in database
GPG Key ID: DA17C4B29CB32E4B
4 changed files with 11 additions and 26 deletions

View File

@ -1 +0,0 @@
Warn when a project's pyproject.toml file does not contain ``build-system.requires``.

View File

@ -1 +0,0 @@
Warn when a project's pyproject.toml file does not contain ``build-system.requires``.

View File

@ -32,7 +32,6 @@ from pip._internal.locations import (
PIP_DELETE_MARKER_FILENAME, running_under_virtualenv, PIP_DELETE_MARKER_FILENAME, running_under_virtualenv,
) )
from pip._internal.req.req_uninstall import UninstallPathSet from pip._internal.req.req_uninstall import UninstallPathSet
from pip._internal.utils.deprecation import deprecated
from pip._internal.utils.hashes import Hashes from pip._internal.utils.hashes import Hashes
from pip._internal.utils.logging import indent_log from pip._internal.utils.logging import indent_log
from pip._internal.utils.misc import ( from pip._internal.utils.misc import (
@ -574,26 +573,10 @@ class InstallRequirement(object):
# Extract the build requirements # Extract the build requirements
requires = pp_toml.get("build-system", {}).get("requires", None) requires = pp_toml.get("build-system", {}).get("requires", None)
template = (
"%s does not comply with PEP 518 since pyproject.toml "
"does not contain a valid '[build-system].requires' key: %s"
)
if requires is None: if requires is None:
logging.warn(template, self, "it is missing.") # We isolate on the presence of the pyproject.toml file.
deprecated( # If build-system.requires is not specified, treat it as if it was
"Future versions of pip may reject packages with " # specified as ["setuptools", "wheel"]
"pyproject.toml files that do not contain the [build-system]"
"table and the requires key, as specified in PEP 518.",
replacement=None,
gone_in="18.2",
issue=5416,
)
# Currently, we're isolating the build based on the presence of the
# pyproject.toml file. If the user doesn't specify
# build-system.requires, assume they intended to use setuptools and
# wheel for now.
return ["setuptools", "wheel"] return ["setuptools", "wheel"]
else: else:
# Error out if it's not a list of strings # Error out if it's not a list of strings
@ -601,8 +584,12 @@ class InstallRequirement(object):
isinstance(req, six.string_types) for req in requires isinstance(req, six.string_types) for req in requires
) )
if not is_list_of_str: if not is_list_of_str:
template = (
"{} does not comply with PEP 518 since pyproject.toml "
"does not contain a valid build-system.requires key: {}"
)
raise InstallationError( raise InstallationError(
template % (self, "it is not a list of strings.") template.format(self, "it is not a list of strings.")
) )
# If control flow reaches here, we're good to go. # If control flow reaches here, we're good to go.

View File

@ -47,14 +47,14 @@ def test_pep518_refuses_invalid_requires(script, data, common_wheels):
assert "does not comply with PEP 518" in result.stderr assert "does not comply with PEP 518" in result.stderr
def test_pep518_allows_but_warns_missing_requires(script, data, common_wheels): def test_pep518_allows_missing_requires(script, data, common_wheels):
result = script.pip( result = script.pip(
'install', '-f', common_wheels, 'install', '-f', common_wheels,
data.src.join("pep518_missing_requires"), data.src.join("pep518_missing_requires"),
expect_stderr=True expect_stderr=True
) )
assert "does not comply with PEP 518" in result.stderr # Make sure we don't warn when this occurs.
assert "DEPRECATION" in result.stderr assert "does not comply with PEP 518" not in result.stderr
# We want it to go through isolation for now. # We want it to go through isolation for now.
assert "Installing build dependencies" in result.stdout, result.stdout assert "Installing build dependencies" in result.stdout, result.stdout