Skip to content

🐛 fix(seed): report a missing seed wheel instead of crashing - #3778

Merged
gaborbernat merged 3 commits into
pypa:mainfrom
waw666waw666:fix/seed-missing-wheel
Dec 4, 2026
Merged

gaborbernat merged 3 commits into
pypa:mainfrom
waw666waw666:fix/seed-missing-wheel

Conversation

@waw666waw666

@waw666waw666 waw666waw666 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

get_wheel documents None as its result when it acquires no wheel without an error, but the seeder stored that None and crashed later, while installing, with AttributeError: 'NoneType' object has no attribute 'version_tuple', which names neither the package nor the cause. 🐛 Seeding now treats a lookup that ends without a wheel like a lookup that raised: it logs could not get wheel for distribution pip and fails with the seeder's usual seed failed due to failing to download wheels pip. A failure from the first lookup attempt is also no longer forgotten when the download attempt then finds nothing.

With the bundled pip and setuptools wheels covering every supported Python, a real install never reaches this, so the example stands in for a lookup that finds nothing:

$ cat run.py
from unittest import mock

from virtualenv import cli_run

with mock.patch("virtualenv.seed.embed.via_app_data.via_app_data.get_wheel", return_value=None):
    cli_run(["env", "--no-setuptools", "--no-periodic-update"])
$ python run.py

With each traceback cut to its last line, and the logged error now shown first:

-AttributeError: 'NoneType' object has no attribute 'version_tuple'
+RuntimeError('could not get wheel for distribution pip')
+RuntimeError: seed failed due to failing to download wheels pip

waw666waw666 and others added 2 commits November 30, 2026 11:12
…rsion_tuple

get_wheel returns None without raising when no wheel can be acquired,
e.g. --pip embed on a Python with no embedded wheel. _get stored that
None into name_to_whl and run() then crashed with a bare AttributeError
on None.version_tuple. Preset failure to a RuntimeError naming the
distribution and only clear it when an attempt finds a wheel, so the
lookup failure is reported through the existing failure path like any
other lookup failure.
@bactiar291

Copy link
Copy Markdown

Checked the added regression test against the PR's exact base and head. On base a7a62938, it fails as expected with AttributeError: 'NoneType' object has no attribute 'version_tuple' in FromAppData.run. On head 7b274360, the new missing-wheel test and the neighboring lookup-error test both pass (2 passed, Python 3.14.9); the lookup-error test also passes alone on base (1 passed). I did not run the full suite.

A Python newer than every bundle reuses the newest one, so --pip embed
never left get_wheel without a wheel; the comment and changelog now
describe the case without that example, and the test drops the comment
that repeated the source.
@gaborbernat gaborbernat changed the title fix(seed): report a missing seed wheel instead of crashing on None.version_tuple 🐛 fix(seed): report a missing seed wheel instead of crashing Dec 4, 2026
@gaborbernat gaborbernat added the bug label Dec 4, 2026
@gaborbernat
gaborbernat merged commit e5eb9db into pypa:main Dec 4, 2026
76 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants