From e9ea3966e0bea469766941ba0e1ef98fac55dc7a Mon Sep 17 00:00:00 2001 From: Sebastian Jordan Date: Sun, 22 Sep 2019 21:24:43 +0200 Subject: [PATCH 1/9] Build pep 517 requirements when installing packages --- src/pip/_internal/commands/install.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index a14b1b38f45..09a6a5c6cc2 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -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 @@ -103,7 +102,7 @@ def check_binary_allowed(req): # type: (InstallRequirement) -> bool canonical_name = canonicalize_name(req.name) allowed_formats = format_control.get_allowed_formats(canonical_name) - return "binary" in allowed_formats + return "binary" in allowed_formats or req.use_pep517 return check_binary_allowed @@ -392,9 +391,8 @@ def run(self, options, args): modifying_pip=modifying_pip ) - check_binary_allowed = get_check_binary_allowed( - finder.format_control - ) + check_binary_allowed = get_check_binary_allowed(finder.format_control) + # Consider legacy and PEP517-using requirements separately legacy_requirements = [] pep517_requirements = [] From 4879c8b2ebff6af72865ec665a16207559b5618b Mon Sep 17 00:00:00 2001 From: Sebastian Jordan Date: Sun, 22 Sep 2019 21:31:45 +0200 Subject: [PATCH 2/9] Linting --- src/pip/_internal/commands/install.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index 09a6a5c6cc2..ce2ec016114 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -391,7 +391,9 @@ def run(self, options, args): modifying_pip=modifying_pip ) - check_binary_allowed = get_check_binary_allowed(finder.format_control) + check_binary_allowed = get_check_binary_allowed( + finder.format_control + ) # Consider legacy and PEP517-using requirements separately legacy_requirements = [] From be6e198875a630e591f8e6f0a576175ebe5ce9b3 Mon Sep 17 00:00:00 2001 From: Sebastian Jordan Date: Wed, 25 Sep 2019 06:32:18 +0200 Subject: [PATCH 3/9] Implement functional test for installing PEP 517 packages with --no-binary :all: --- .../pep517_setup_and_pyproject/pyproject.toml | 3 +++ .../pep517_setup_and_pyproject/setup.cfg | 3 +++ .../pep517_setup_and_pyproject/setup.py | 3 +++ tests/functional/test_install.py | 17 +++++++++++++++++ 4 files changed, 26 insertions(+) create mode 100644 tests/data/packages/pep517_setup_and_pyproject/pyproject.toml create mode 100644 tests/data/packages/pep517_setup_and_pyproject/setup.cfg create mode 100644 tests/data/packages/pep517_setup_and_pyproject/setup.py diff --git a/tests/data/packages/pep517_setup_and_pyproject/pyproject.toml b/tests/data/packages/pep517_setup_and_pyproject/pyproject.toml new file mode 100644 index 00000000000..86df60002ac --- /dev/null +++ b/tests/data/packages/pep517_setup_and_pyproject/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = [ "setuptools" ] +build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/tests/data/packages/pep517_setup_and_pyproject/setup.cfg b/tests/data/packages/pep517_setup_and_pyproject/setup.cfg new file mode 100644 index 00000000000..88446933ec6 --- /dev/null +++ b/tests/data/packages/pep517_setup_and_pyproject/setup.cfg @@ -0,0 +1,3 @@ +[metadata] +name = pep517-setup-and-pyproject +version = 1.0 \ No newline at end of file diff --git a/tests/data/packages/pep517_setup_and_pyproject/setup.py b/tests/data/packages/pep517_setup_and_pyproject/setup.py new file mode 100644 index 00000000000..606849326a4 --- /dev/null +++ b/tests/data/packages/pep517_setup_and_pyproject/setup.py @@ -0,0 +1,3 @@ +from setuptools import setup + +setup() diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py index 7a0e4a9cbee..3cbd59b070a 100644 --- a/tests/functional/test_install.py +++ b/tests/functional/test_install.py @@ -1268,6 +1268,23 @@ 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-and-pyproject" in str(res), str(res) + assert ( + "Running setup.py install for pep517-setup-and-pyproject" \ + not in str(res), + str(res) + ) + + def test_install_no_binary_disables_cached_wheels(script, data, with_wheel): # Seed the cache script.pip( From 58eb90ff80e4537175a481143992d7ee23ec2988 Mon Sep 17 00:00:00 2001 From: Sebastian Jordan Date: Wed, 25 Sep 2019 06:37:02 +0200 Subject: [PATCH 4/9] Fix code layout problems in test_install.py --- tests/functional/test_install.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py index 3cbd59b070a..7b65e3104d2 100644 --- a/tests/functional/test_install.py +++ b/tests/functional/test_install.py @@ -1277,12 +1277,8 @@ def test_install_no_binary_builds_pep_517_wheel(script, data, with_wheel): # Must have installed the package assert expected in str(res), str(res) - assert "Building wheel for pep517-setup-and-pyproject" in str(res), str(res) - assert ( - "Running setup.py install for pep517-setup-and-pyproject" \ - not 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): From dd842fd71e1a4b85d51bf8485753bc09f587d113 Mon Sep 17 00:00:00 2001 From: Sebastian Jordan Date: Wed, 25 Sep 2019 06:54:00 +0200 Subject: [PATCH 5/9] Add news entry --- news/6606.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/6606.bugfix diff --git a/news/6606.bugfix b/news/6606.bugfix new file mode 100644 index 00000000000..990a7570121 --- /dev/null +++ b/news/6606.bugfix @@ -0,0 +1 @@ +Fix bug that prevented installation of PEP 517 packages without `setup.py` \ No newline at end of file From 7a0f7b607defc078a8c774c15d6814511a68d937 Mon Sep 17 00:00:00 2001 From: Sebastian Jordan Date: Wed, 25 Sep 2019 06:58:53 +0200 Subject: [PATCH 6/9] Improve check_binary_allowed via early return --- src/pip/_internal/commands/install.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index ce2ec016114..c91f6b8f1c3 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -100,9 +100,11 @@ 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 or req.use_pep517 + return "binary" in allowed_formats return check_binary_allowed From cd0d6e82391545a86e2d906afad8bab289f1f9ad Mon Sep 17 00:00:00 2001 From: Sebastian Jordan Date: Wed, 25 Sep 2019 07:04:56 +0200 Subject: [PATCH 7/9] Delete unnecessary empty line addition --- src/pip/_internal/commands/install.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index c91f6b8f1c3..04e28e755ca 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -396,7 +396,6 @@ def run(self, options, args): check_binary_allowed = get_check_binary_allowed( finder.format_control ) - # Consider legacy and PEP517-using requirements separately legacy_requirements = [] pep517_requirements = [] From 28f3dcc64142d9ae427442710931049aae7c6adc Mon Sep 17 00:00:00 2001 From: Sebastian Jordan Date: Sat, 12 Oct 2019 12:19:52 +0200 Subject: [PATCH 8/9] Add missing newline characters in pep517_setup_and_pyproject test data --- tests/data/packages/pep517_setup_and_pyproject/pyproject.toml | 2 +- tests/data/packages/pep517_setup_and_pyproject/setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/data/packages/pep517_setup_and_pyproject/pyproject.toml b/tests/data/packages/pep517_setup_and_pyproject/pyproject.toml index 86df60002ac..5a561e83317 100644 --- a/tests/data/packages/pep517_setup_and_pyproject/pyproject.toml +++ b/tests/data/packages/pep517_setup_and_pyproject/pyproject.toml @@ -1,3 +1,3 @@ [build-system] requires = [ "setuptools" ] -build-backend = "setuptools.build_meta" \ No newline at end of file +build-backend = "setuptools.build_meta" diff --git a/tests/data/packages/pep517_setup_and_pyproject/setup.cfg b/tests/data/packages/pep517_setup_and_pyproject/setup.cfg index 88446933ec6..7eae9c0111e 100644 --- a/tests/data/packages/pep517_setup_and_pyproject/setup.cfg +++ b/tests/data/packages/pep517_setup_and_pyproject/setup.cfg @@ -1,3 +1,3 @@ [metadata] name = pep517-setup-and-pyproject -version = 1.0 \ No newline at end of file +version = 1.0 From 483daaba439cc1bdad76b706ed547a61d4c19667 Mon Sep 17 00:00:00 2001 From: Sebastian Jordan Date: Sat, 12 Oct 2019 13:17:43 +0200 Subject: [PATCH 9/9] Add trailing newline in news/6606.bugfix --- news/6606.bugfix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/6606.bugfix b/news/6606.bugfix index 990a7570121..3fbf7262f14 100644 --- a/news/6606.bugfix +++ b/news/6606.bugfix @@ -1 +1 @@ -Fix bug that prevented installation of PEP 517 packages without `setup.py` \ No newline at end of file +Fix bug that prevented installation of PEP 517 packages without ``setup.py``.