Skip to content

Commit

Permalink
Fix PEP 517 builds for packages without setup.py (pypa#6606)
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg authored and xavfernandez committed Oct 17, 2019
1 parent 4bc7297 commit 6ee768a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 1 deletion.
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

0 comments on commit 6ee768a

Please sign in to comment.