From e47734ed033d1ddc41fbc6d9dd71d55c2af52a54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Mon, 14 Dec 2020 14:56:07 +0100 Subject: [PATCH 1/3] Add failing test that pip wheel -e keeps git clone in src --- tests/functional/test_wheel.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/functional/test_wheel.py b/tests/functional/test_wheel.py index 286d69435..f780130c9 100644 --- a/tests/functional/test_wheel.py +++ b/tests/functional/test_wheel.py @@ -169,6 +169,25 @@ def test_pip_wheel_builds_editable(script, data): result.did_create(wheel_file_path) +@pytest.mark.network +def test_pip_wheel_git_editable_keeps_clone(script, tmpdir): + """ + Test that `pip wheel -e giturl` preserves a git clone in src. + """ + script.pip( + 'wheel', + '--no-deps', + '-e', + 'git+https://github.com/pypa/pip-test-package#egg=pip-test-package', + '--src', + tmpdir / 'src', + '--wheel-dir', + tmpdir, + ) + assert (tmpdir / 'src' / 'pip-test-package').exists() + assert (tmpdir / 'src' / 'pip-test-package' / '.git').exists() + + def test_pip_wheel_builds_editable_does_not_create_zip(script, data, tmpdir): """ Test 'pip wheel' of editables does not create zip files From 4ea00f2f1b988272132f06d0987ba27dc10395de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Wed, 23 Dec 2020 10:42:48 +0100 Subject: [PATCH 2/3] The preparer always clones VCS requirements Previously, in download mode, it did a vcs export, which did not include vcs information, leading to issues when the build backend required it. --- src/pip/_internal/operations/prepare.py | 2 +- src/pip/_internal/req/req_install.py | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/pip/_internal/operations/prepare.py b/src/pip/_internal/operations/prepare.py index 13b2c0bee..da2fea088 100644 --- a/src/pip/_internal/operations/prepare.py +++ b/src/pip/_internal/operations/prepare.py @@ -570,7 +570,7 @@ class RequirementPreparer(object): 'hash.'.format(req) ) req.ensure_has_source_dir(self.src_dir) - req.update_editable(self.download_dir is None) + req.update_editable() dist = _get_prepared_distribution( req, self.req_tracker, self.finder, self.build_isolation, diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py index 866d18fcb..357dbceac 100644 --- a/src/pip/_internal/req/req_install.py +++ b/src/pip/_internal/req/req_install.py @@ -617,8 +617,8 @@ class InstallRequirement(object): ) # For editable installations - def update_editable(self, obtain=True): - # type: (bool) -> None + def update_editable(self): + # type: () -> None if not self.link: logger.debug( "Cannot update repository at %s; repository location is " @@ -651,10 +651,7 @@ class InstallRequirement(object): ) deprecated(reason, replacement, gone_in="21.0", issue=7554) hidden_url = hide_url(self.link.url) - if obtain: - vcs_backend.obtain(self.source_dir, url=hidden_url) - else: - vcs_backend.export(self.source_dir, url=hidden_url) + vcs_backend.obtain(self.source_dir, url=hidden_url) else: assert 0, ( 'Unexpected version control type (in {}): {}'.format( From 9361faa03ee75cbfad58d7546fb8a7196e85fa79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Wed, 23 Dec 2020 12:26:22 +0100 Subject: [PATCH 3/3] Add newfragments --- news/9273.bugfix.rst | 3 +++ news/9337.bugfix.rst | 2 ++ news/9338.removal.rst | 2 ++ 3 files changed, 7 insertions(+) create mode 100644 news/9273.bugfix.rst create mode 100644 news/9337.bugfix.rst create mode 100644 news/9338.removal.rst diff --git a/news/9273.bugfix.rst b/news/9273.bugfix.rst new file mode 100644 index 000000000..e729ea294 --- /dev/null +++ b/news/9273.bugfix.rst @@ -0,0 +1,3 @@ +Fix a regression that made ``pip wheel`` do a VCS export instead of a VCS clone +for editable requirements. This broke VCS requirements that need the VCS +information to build correctly. diff --git a/news/9337.bugfix.rst b/news/9337.bugfix.rst new file mode 100644 index 000000000..e9d08c3ad --- /dev/null +++ b/news/9337.bugfix.rst @@ -0,0 +1,2 @@ +Fix ``pip download`` of editable VCS requirements that need VCS information +to build correctly. diff --git a/news/9338.removal.rst b/news/9338.removal.rst new file mode 100644 index 000000000..6d3b666e5 --- /dev/null +++ b/news/9338.removal.rst @@ -0,0 +1,2 @@ +Remove the VCS export feature that was used only with editable VCS +requirements and had correctness issues.