Skip to content

Commit

Permalink
Allow empty string as version for find_compatible_in_house (#2430)
Browse files Browse the repository at this point in the history
The empty string is used in several locations to indicate the newest
version. Interpret it as such instead of rejecting it as invalid.
  • Loading branch information
schaap committed Oct 8, 2022
1 parent 3ed75b2 commit cdf4225
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/changelog/2429.bugfix.rst
@@ -0,0 +1 @@
Fix fallback handling of downloading wheels for bundled packages - by :user:`schaap`.
2 changes: 1 addition & 1 deletion src/virtualenv/seed/wheels/acquire.py
Expand Up @@ -83,7 +83,7 @@ def _find_downloaded_wheel(distribution, version_spec, for_py_version, to_folder
def find_compatible_in_house(distribution, version_spec, for_py_version, in_folder):
wheels = discover_wheels(in_folder, distribution, None, for_py_version)
start, end = 0, len(wheels)
if version_spec is not None:
if version_spec is not None and version_spec != "":
if version_spec.startswith("<"):
from_pos, op = 1, lt
elif version_spec.startswith("=="):
Expand Down
8 changes: 7 additions & 1 deletion tests/unit/seed/wheels/test_acquire_find_wheel.py
Expand Up @@ -4,12 +4,18 @@
from virtualenv.seed.wheels.embed import BUNDLE_FOLDER, MAX, get_embed_wheel


def test_find_latest(for_py_version):
def test_find_latest_none(for_py_version):
result = find_compatible_in_house("setuptools", None, for_py_version, BUNDLE_FOLDER)
expected = get_embed_wheel("setuptools", for_py_version)
assert result.path == expected.path


def test_find_latest_string(for_py_version):
result = find_compatible_in_house("setuptools", "", for_py_version, BUNDLE_FOLDER)
expected = get_embed_wheel("setuptools", for_py_version)
assert result.path == expected.path


def test_find_exact(for_py_version):
expected = get_embed_wheel("setuptools", for_py_version)
result = find_compatible_in_house("setuptools", f"=={expected.version}", for_py_version, BUNDLE_FOLDER)
Expand Down

0 comments on commit cdf4225

Please sign in to comment.