-
-
Notifications
You must be signed in to change notification settings - Fork 526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only return Python factor on base_python conflict #2840
Conversation
60fa657
to
c26da88
Compare
We must support this, and I cannot accept a change that would introduce this regression. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We must support this, and I cannot accept a change that would introduce this regression.
But why? Who is the target user here? Who needs this functionality? fwiw, I added documentation on how factors worked (since there wasn't any before then) way back in #1573 that seems to have been lost in the rewrite, but when researching that there was no suggesting that e.g. If you need to support this, how do you propose determining whether something is a factor or not? For example, what would the Python versions used in each of the below be?
While you're considering answers for these, please note how much cognitive effort is required for each, compared to simply supporting Personally, I think we're tacking too close to what [testenv:py310]
base_python = python3.10-64 |
https://virtualenv.pypa.io/en/latest/user_guide.html#python-discovery
So only envs with either of those two factors should be accepted and the rest not.
I'd actually consider that a feature, not a bug. I want tox to differ as little as possible from virtualenv to have only one way of doing thins. |
As I noted above though, this means we can no longer delimit by hyphens alone, yes? We need to lookahead, check if any of the "factors" are Can you propose something we can slot into the documentation because I'm struggling to explain this in a way that doesn't make tox factors sound even more "magical" (in a bad way).
I respectfully disagree. This isn't a helpful goal for normal end-users who only care about tox for its automation of virtualenvs. If power users want a very specific python version (say, the 32 bit version of Python), they can specify |
You are correct 😊
Hmm, I never considered this a hard rule 🤔 and this still can be the case, no; just look ahead. I personally consider it a feature that you can use the same names in virtualenv spec as your tox env names 🤔 So seem we will need to disagree on this. |
I had a go at doing ☝️ Just to note, I don't like this in the slightest. I feel it's too confusing and reinforces what I feel is a UX regression in tox 4. IMO, the call to |
Understood, I'll think about it. I'll also invite the other maintainers, @jugmac00 and @asottile, to comment on their opinions. |
Thanks, I appreciate it 👍 |
Let's remove the arch support in factors, for now, the 🤔 (the only support I could find was https://tox.wiki/en/legacy/example/basic.html#using-generative-section-names, but that's also just setting basepython instead). |
If you remove the last commit I'll accept this 👍 @stephenfin |
@@ -0,0 +1,2 @@ | |||
A testenv with multiple factors, one of which conflicts with a ``base_python`` setting in ``tox.ini``, will now use the | |||
correct Python interpreter version - by :user:`stephenfin`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"the correct Python version" - that would be which one? The one from base_python or from the factor? And while I could read the source code, I'd prefer to have it here, too.
As you are very involved in that topic... is this properly documented? Or do you think it would make sense to update the documentation, too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be the version derived from the factor. If I run tox -e py310
, I expect to get python3.10
.
I did have this documented as part of #841 but that seems to have been lost in the rewrite. I can do another PR to (re-)flesh out the documentation. I also need to re-add docs explaining how factors work, which I'd done previously in #1573.
@gaborbernat Unfortunately, I am currently lacking the time to dig deeper in this topic. I rarely used I am very happy that there is some in-depth discussion going on, as I think we really should be careful about introducing more breaking changes. |
I think the docs you want are here https://tox.wiki/en/legacy/config.html#tox-environments ? That details the "special'ness" of Note, I wrote those based on reverse engineering how |
Consider the following 'tox.ini' file: [tox] ignore_base_python_conflict = true [testenv] base_python = python3 commands = ... [testenv:functional{,-py38,-py39,-py310}] commands = ... There is a conflict between the base_python value specified in '[testenv] base_python' and the value implied by the 'pyXY' factors in the 'functional-pyXY' test envs. The 'Python._validate_base_python' function is supposed to resolve this for us and either (a) raise an error if '[tox] ignore_base_python_conflict' is set to 'false' (default) or (b) ignore the value of '[testenv] base_python' in favour of the value implied by the 'pyXY' factor for the given test env if '[tox] ignore_base_python_conflict' is set to 'true'. There's a bug though. Rather than returning the 'pyXY' factor, we were returning the entire test env name ('functional-pyXY'). There is no Python version corresponding to e.g. 'functional-py39' so this (correctly) fails. We can correct the issue by only returning the factor that modified the base_python value, i.e. the 'pyXY' factor. To ensure we do this, we need some additional logic. It turns out this logic is already present in another helper method on the 'Python' class, 'extract_base_python', so we also take the opportunity to de-duplicate and reuse some logic. Note that this change breaks the ability of users to use a testenv name like 'py38-64' (to get the 64 bit version of a Python 3.8 interpreter). Continuing to support this would require much larger change since we'd no longer be able to strictly delimit factors by hyphens (in this case, the entirety of 'py38-64' becomes a factor). Also note that this change emphasises issue tox-dev#2657, as this will now be raised for a factor like 'py38-64' since 'tox' (or rather, virtualenv) is falsely identifying '64' as a valid Python interpreter identifier. We will fix this separately so the offending test are skipped for now. Signed-off-by: Stephen Finucane <[email protected]> Fixes: tox-dev#2838
66ff10d
to
e075089
Compare
Done. I had to force push so I also took the opportunity to rebase. |
This PR contains the following updates: | Package | Type | Update | Change | Pending | |---|---|---|---|---| | [tox](https://togithub.com/tox-dev/tox) ([changelog](https://tox.wiki/en/latest/changelog.html)) | dev | patch | `4.2.6` -> `4.2.8` | `4.4.2` (+8) | --- ### Release Notes <details> <summary>tox-dev/tox</summary> ### [`v4.2.8`](https://togithub.com/tox-dev/tox/releases/tag/4.2.8) [Compare Source](https://togithub.com/tox-dev/tox/compare/4.2.7...4.2.8) #### What's Changed - Allow package names with env markers with pip binary options by [@​q0w](https://togithub.com/q0w) in [https://github.com/tox-dev/tox/pull/2853](https://togithub.com/tox-dev/tox/pull/2853) **Full Changelog**: tox-dev/tox@4.2.7...4.2.8 ### [`v4.2.7`](https://togithub.com/tox-dev/tox/releases/tag/4.2.7) [Compare Source](https://togithub.com/tox-dev/tox/compare/4.2.6...4.2.7) #### What's Changed - Add release notes project URL for quick access in PyPI web by [@​scop](https://togithub.com/scop) in [https://github.com/tox-dev/tox/pull/2835](https://togithub.com/tox-dev/tox/pull/2835) - Document colorization regression on Windows by [@​adamchainz](https://togithub.com/adamchainz) in [https://github.com/tox-dev/tox/pull/2837](https://togithub.com/tox-dev/tox/pull/2837) - The tests actually require wheel by [@​hroncok](https://togithub.com/hroncok) in [https://github.com/tox-dev/tox/pull/2843](https://togithub.com/tox-dev/tox/pull/2843) - Only return Python factor on base_python conflict by [@​stephenfin](https://togithub.com/stephenfin) in [https://github.com/tox-dev/tox/pull/2840](https://togithub.com/tox-dev/tox/pull/2840) - Revert to supporting simple Python factors by [@​stephenfin](https://togithub.com/stephenfin) in [https://github.com/tox-dev/tox/pull/2849](https://togithub.com/tox-dev/tox/pull/2849) **Full Changelog**: tox-dev/tox@4.2.6...4.2.7 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xMDEuMCIsInVwZGF0ZWRJblZlciI6IjM0LjEwMS4wIn0=--> Co-authored-by: descope[bot] <descope[bot]@users.noreply.github.com>
Consider the following
tox.ini
file:There is a conflict between the
base_python
value specified in[testenv] base_python
and the value implied by thepyXY
factors in thefunctional-pyXY
test envs. ThePython._validate_base_python
function is supposed to resolve this for us and either (a) raise an error if[tox] ignore_base_python_conflict
is set tofalse
(default) or (b) ignore the value of[testenv] base_python
in favour of the value implied by thepyXY
factor for the given test env if[tox] ignore_base_python_conflict
is set totrue
. There's a bug though. Rather than returning thepyXY
factor, we were returning the entire test env name (functional-pyXY
). There is no Python version corresponding to e.g.functional-py39
so this (correctly) fails.We can correct the issue by only returning the factor that modified the
base_python
value, i.e. thepyXY
factor. To ensure we do this, we need some additional logic. It turns out this logic is already present in another helper method on thePython
class,extract_base_python
, so we also take the opportunity to de-duplicate and reuse some logic.Note that this change breaks the ability of users to use a testenv name like
py38-64
(to get the 64 bit version of a Python 3.8 interpreter). Continuing to support this would require much larger change since we'd no longer be able to strictly delimit factors by hyphens (in this case, the entirety ofpy38-64
becomes a factor).Also note that this change emphasises issue #2657, as this will now be raised for a factor like
py38-64
sincetox
(or rather, virtualenv) is falsely identifying64
as a valid Python interpreter identifier. We will fix this separately so the offending test are skipped for now.Signed-off-by: Stephen Finucane [email protected]
Fixes: #2838
Thanks for contribution
Please, make sure you address all the checklists (for details on how see
development documentation)!
tox -e fix
)docs/changelog
folder