Skip to content

Commit

Permalink
Only disable isolation when build-system.requires is skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg committed Jun 19, 2018
1 parent 8f1cd5f commit 2b68c79
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 16 deletions.
35 changes: 24 additions & 11 deletions src/pip/_internal/req/req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
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 (
Expand Down Expand Up @@ -575,22 +577,33 @@ def get_pep_518_info(self):
# 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
Expand Down
20 changes: 15 additions & 5 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2b68c79

Please sign in to comment.