Skip to content

Fix compatibility with virtualenv 21.0.0#2195

Closed
RRosio wants to merge 2 commits intopypa:masterfrom
RRosio:fix_import
Closed

Fix compatibility with virtualenv 21.0.0#2195
RRosio wants to merge 2 commits intopypa:masterfrom
RRosio:fix_import

Conversation

@RRosio
Copy link
Copy Markdown

@RRosio RRosio commented Feb 26, 2026

A few hours ago, virtualenv 21.0.0 was released, and it extracted the Python discovery logic
into a standalone python-discovery package (pypa/virtualenv#3070). As part of this refactoring, propose_interpreters is no longer exported from virtualenv.discovery.builtin, causing hatch to fail with:

Environment `my-env-name` is incompatible: module 'virtualenv.discovery.builtin' has no attribute 'propose_interpreters'

This PR adds a fallback import from python_discovery._discovery (which is installed as a dependency of virtualenv >=21).

The related issue is #2193.

I've tested this locally and it resolved the issue for me.

This is my first contribution to hatch, so I'm happy to adjust the approach if maintainers prefer a different direction!

@RRosio RRosio marked this pull request as ready for review February 26, 2026 02:58
@flying-sheep
Copy link
Copy Markdown
Contributor

flying-sheep commented Feb 26, 2026

I don’t think this makes sense, the monkeypatch sets the propose_interpreters attribute on virtualenv.discovery.builtin, but that module no longer has a propose_interpreters function. That function presumably lives in python-discovery now and would need to be patched there.

But as @agriyakhetarpal said, there’s no reason to import this from virtualenv.discovery.builtin anymore, get_interpreter should be directly imported from python-discovery.

After a hotfix, I think it’s best to take this upstream so it never breaks again. This would probably mean to add a filter parameter in python-discovery or so.

@flying-sheep
Copy link
Copy Markdown
Contributor

python-discovery was updated to accomodate our use case, so no more monkeypatching necessary.

I made a PR based on the new API: #2196

@RRosio
Copy link
Copy Markdown
Author

RRosio commented Feb 26, 2026

@flying-sheep thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants