Merge pull request #9123 from sbidoul/pip-wheel-editable-fix-sbi

This commit is contained in:
Pradyun Gedam 2020-11-22 21:32:44 +00:00 committed by GitHub
commit aa847eaa8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 3 deletions

2
news/9122.bugfix.rst Normal file
View File

@ -0,0 +1,2 @@
Fix a regression that made ``pip wheel`` generate zip files of editable
requirements in the wheel directory.

View File

@ -132,7 +132,7 @@ class DownloadCommand(RequirementCommand):
downloaded = [] # type: List[str]
for req in requirement_set.requirements.values():
if not req.editable and req.satisfied_by is None:
if req.satisfied_by is None:
assert req.name is not None
preparer.save_linked_requirement(req)
downloaded.append(req.name)

View File

@ -530,7 +530,7 @@ class RequirementPreparer(object):
assert self.download_dir is not None
assert req.link is not None
link = req.link
if link.is_vcs:
if link.is_vcs or (link.is_existing_dir() and req.editable):
# Make a .zip of the source_dir we already created.
req.archive(self.download_dir)
return
@ -576,7 +576,6 @@ class RequirementPreparer(object):
req, self.req_tracker, self.finder, self.build_isolation,
)
req.archive(self.download_dir)
req.check_if_exists(self.use_user_site)
return dist

View File

@ -849,3 +849,19 @@ def test_download_http_url_bad_hash(
assert len(requests) == 1
assert requests[0]['PATH_INFO'] == '/simple-1.0.tar.gz'
assert requests[0]['HTTP_ACCEPT_ENCODING'] == 'identity'
def test_download_editable(script, data, tmpdir):
"""
Test 'pip download' of editables in requirement file.
"""
editable_path = str(data.src / 'simplewheel-1.0').replace(os.path.sep, "/")
requirements_path = tmpdir / "requirements.txt"
requirements_path.write_text("-e " + editable_path + "\n")
download_dir = tmpdir / "download_dir"
script.pip(
'download', '--no-deps', '-r', str(requirements_path), '-d', str(download_dir)
)
downloads = os.listdir(download_dir)
assert len(downloads) == 1
assert downloads[0].endswith(".zip")

View File

@ -169,6 +169,22 @@ def test_pip_wheel_builds_editable(script, data):
result.did_create(wheel_file_path)
def test_pip_wheel_builds_editable_does_not_create_zip(script, data, tmpdir):
"""
Test 'pip wheel' of editables does not create zip files
(regression test for issue #9122)
"""
wheel_dir = tmpdir / "wheel_dir"
wheel_dir.mkdir()
editable_path = os.path.join(data.src, 'simplewheel-1.0')
script.pip(
'wheel', '--no-deps', '-e', editable_path, '-w', wheel_dir
)
wheels = os.listdir(wheel_dir)
assert len(wheels) == 1
assert wheels[0].endswith(".whl")
def test_pip_wheel_fail(script, data):
"""
Test 'pip wheel' failure.