Skip to content
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

Merged
merged 1 commit into from
Jan 10, 2023

Commits on Jan 10, 2023

  1. Only return Python factor on base_python conflict

    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 <stephen@that.guru>
    Fixes: tox-dev#2838
    stephenfin committed Jan 10, 2023
    Configuration menu
    Copy the full SHA
    e075089 View commit details
    Browse the repository at this point in the history