Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PEP 517 builds for packages without setup.py #6606

Merged
merged 11 commits into from
Oct 17, 2019
Merged
1 change: 1 addition & 0 deletions news/6606.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug that prevented installation of PEP 517 packages without ``setup.py``.
3 changes: 2 additions & 1 deletion src/pip/_internal/commands/install.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# The following comment should be removed at some point in the future.
# It's included for now because without it InstallCommand.run() has a
# couple errors where we have to know req.name is str rather than
Expand Down Expand Up @@ -102,6 +101,8 @@ def get_check_binary_allowed(format_control):
# type: (FormatControl) -> BinaryAllowedPredicate
def check_binary_allowed(req):
# type: (InstallRequirement) -> bool
if req.use_pep517:
return True
canonical_name = canonicalize_name(req.name)
allowed_formats = format_control.get_allowed_formats(canonical_name)
return "binary" in allowed_formats
Expand Down
3 changes: 3 additions & 0 deletions tests/data/packages/pep517_setup_and_pyproject/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = [ "setuptools" ]
build-backend = "setuptools.build_meta"
3 changes: 3 additions & 0 deletions tests/data/packages/pep517_setup_and_pyproject/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[metadata]
name = pep517-setup-and-pyproject
version = 1.0
3 changes: 3 additions & 0 deletions tests/data/packages/pep517_setup_and_pyproject/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from setuptools import setup

setup()
13 changes: 13 additions & 0 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,19 @@ def test_install_no_binary_disables_building_wheels(script, data, with_wheel):
assert "Running setup.py install for upper" in str(res), str(res)


def test_install_no_binary_builds_pep_517_wheel(script, data, with_wheel):
to_install = data.packages.joinpath('pep517_setup_and_pyproject')
res = script.pip(
'install', '--no-binary=:all:', '-f', data.find_links, to_install
)
expected = ("Successfully installed pep517-setup-and-pyproject")
# Must have installed the package
assert expected in str(res), str(res)

assert "Building wheel for pep517-setup" in str(res), str(res)
assert "Running setup.py install for pep517-set" not in str(res), str(res)


def test_install_no_binary_disables_cached_wheels(script, data, with_wheel):
# Seed the cache
script.pip(
Expand Down