summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPradyun Gedam <pradyunsg@gmail.com>2018-06-19 15:28:32 +0530
committerPradyun Gedam <pradyunsg@gmail.com>2018-06-19 16:27:07 +0530
commit2b68c7983e1a71efe8cf638a34d515d909c26932 (patch)
tree219ed1710b791f3e1118fe70c04127ebdc67a497
parent8f1cd5fa40ea7842c6e2d82a28537256d8015cc4 (diff)
downloadpip-2b68c7983e1a71efe8cf638a34d515d909c26932.tar.gz
Only disable isolation when build-system.requires is skipped
-rw-r--r--src/pip/_internal/req/req_install.py35
-rw-r--r--tests/functional/test_install.py20
2 files changed, 39 insertions, 16 deletions
diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py
index 7a24af16c..bd6d4e9fe 100644
--- a/src/pip/_internal/req/req_install.py
+++ b/src/pip/_internal/req/req_install.py
@@ -33,7 +33,9 @@ from pip._internal.locations import (
PIP_DELETE_MARKER_FILENAME, running_under_virtualenv,
)
from pip._internal.req.req_uninstall import UninstallPathSet
-from pip._internal.utils.deprecation import RemovedInPip11Warning
+from pip._internal.utils.deprecation import (
+ RemovedInPip11Warning, RemovedInPip12Warning,
+)
from pip._internal.utils.hashes import Hashes
from pip._internal.utils.logging import indent_log
from pip._internal.utils.misc import (
@@ -575,22 +577,33 @@ class InstallRequirement(object):
# Extract the build requirements
requires = pp_toml.get("build-system", {}).get("requires", None)
- # Error out if it's not valid
- error_reason = 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:
- error_reason = "is missing."
+ logging.warn(template, self, "it is missing.")
+ warnings.warn(
+ "Future versions of pip will reject packages with "
+ "pyproject.toml files that do not comply with PEP 518.",
+ RemovedInPip12Warning,
+ )
+
+ # NOTE: Currently allowing projects to skip this key so that they
+ # can transition to a PEP 518 compliant pyproject.toml or
+ # push to update the PEP.
+ # Come pip 19.0, bring this to compliance with PEP 518.
+ return None
else:
+ # Error out if it's not a list of strings
is_list_of_str = isinstance(requires, list) and all(
isinstance(req, six.string_types) for req in requires
)
if not is_list_of_str:
- error_reason = "not a list of strings."
- if error_reason is not None:
- msg = (
- "{} does not comply with PEP 518 since pyproject.toml does "
- "not contain a valid '[build-system].requires' key: {}"
- ).format(self, error_reason)
- raise InstallationError(msg)
+ raise InstallationError(
+ template % (self, "it is not a list of strings.")
+ )
# If control flow reaches here, we're good to go.
return requires
diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py
index 2a97f9216..b10251907 100644
--- a/tests/functional/test_install.py
+++ b/tests/functional/test_install.py
@@ -37,18 +37,28 @@ def test_pep518_uses_build_env(script, data, common_wheels, command, variant):
)
-@pytest.mark.parametrize(
- "package", ["pep518_invalid_requires", "pep518_missing_requires"]
-)
-def test_pep518_refuses_invalid_requires(script, data, common_wheels, package):
+def test_pep518_refuses_invalid_requires(script, data, common_wheels):
result = script.pip(
- 'install', '-f', common_wheels, data.src.join(package),
+ 'install', '-f', common_wheels,
+ data.src.join("pep518_invalid_requires"),
expect_error=True
)
assert result.returncode == 1
assert "does not comply with PEP 518" in result.stderr
+def test_pep518_allows_but_warns_missing_requires(script, data, common_wheels):
+ result = script.pip(
+ 'install', '-f', common_wheels,
+ data.src.join("pep518_missing_requires"),
+ expect_stderr=True
+ )
+ assert "does not comply with PEP 518" in result.stderr
+ assert "DEPRECATION" in result.stderr
+ assert result.returncode == 0
+ assert result.files_created
+
+
def test_pep518_with_user_pip(script, virtualenv, pip_src,
data, common_wheels):
virtualenv.system_site_packages = True