virtualenv
virtualenv copied to clipboard
Document interaction of --python, --try-first-with, and $VIRTUALENV_PYTHON and fix inconsistencies
Issue
Like @kapec94 in #2659, I came across confusing interaction between these parameters in Poetry (see my comment on 9278). I think, now, that part of the problem I was seeing then was Debian's python3-virtualenv, but I think I've compiled a list of problems using this demonstration script (output).
Interesting points:
| ENV | python flag | try-first-with | activated | notes | |
|---|---|---|---|---|---|
| ~/.asdf/installs/python/3.9.19/bin/python3.9 | 3.9.19 | ✅ | try-first-with is used and path is ignored | ||
| 3.9 | ~/.asdf/installs/python/3.9.19/bin/python3.9 | 3.9.19 | ✅ | try-first-with provides matching python | |
| 3.9 | ~/.asdf/installs/python/3.11.9/bin/python3.11 | 3.9.2 | ✅ | try-first-with is ignored b/c wrong version, found python in path | |
| ~/.asdf/installs/python/3.11.9/bin/python3.11 | ~/.asdf/installs/python/3.9.19/bin/python3.9 | 3.9.19 | ❌ | python flag should be used (See this comment on #2659) | |
| 3.9 | 3.11 | ~/.asdf/installs/python/3.11.9/bin/python3.11 | 3.9.2 | ❌ | python flag should override env (See this comment on #2285) |
Creating a new issue to focus the work.