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

Test Python 3.10 support #10164

Merged
merged 5 commits into from
Aug 7, 2021
Merged

Test Python 3.10 support #10164

merged 5 commits into from
Aug 7, 2021

Conversation

pradyunsg
Copy link
Member

@pradyunsg pradyunsg commented Jul 16, 2021

We're still gonna be on the legacy branch of virtualenv, but hopefully this helps us move forward soon.

@pradyunsg
Copy link
Member Author

/cc @hugovk, since they had looked into this earlier?

@pradyunsg
Copy link
Member Author

Ok, cool. So, our tests can be run like this. Now, who wants to actually fix the two failures? :)

@puetzk
Copy link
Contributor

puetzk commented Jul 16, 2021

test_pip_works_with_warnings_as_errors just seems to be assertion errors on the distutils deprecation from within packaging.tags, which should be fixed by #10144

I'm not sure what's going on in test_correct_pip_version, obviously the regex didn't match, but it didn't capture what pip --version did print.

@puetzk
Copy link
Contributor

puetzk commented Jul 16, 2021

Oh duh, the regex at

r"\(python \d(.[\d])+\)$",
doesn't allow for two-digit version numbers (needs to be [\d]+)

@puetzk
Copy link
Contributor

puetzk commented Jul 16, 2021

I guess in the past python only got to 1.6 and 2.7, so 3.10 it's the first time that's ever happened in the major or minor :-)

@pradyunsg
Copy link
Member Author

Okay, those seem easy and my Internet provider has restored the connection now.

@hugovk
Copy link
Contributor

hugovk commented Jul 17, 2021

Pinning 3.10.0-beta.4 in GitHub Actions is the safest option, but 3.10-dev should track the 1-2 RC releases too.

And the beta should be pretty stable, and if not, we probably want to know about it sooner to report upstream.

@hugovk
Copy link
Contributor

hugovk commented Jul 17, 2021

Oh duh, the regex at

r"\(python \d(.[\d])+\)$",

doesn't allow for two-digit version numbers (needs to be [\d]+)

Tip: run https://github.com/asottile/flake8-2020 to find other possible problems introduced by the first-ever two-digit minor version. I think pip is good, worth a quick check again.

@uranusjr
Copy link
Member

uranusjr commented Jul 17, 2021

IIRC someone already did that on the main code base a while ago, back when 3.10 was first confirmed to going to happen.

@pradyunsg
Copy link
Member Author

IIRC Anthony did that for pip when he wrote flake8-2020.

@pradyunsg pradyunsg marked this pull request as ready for review July 23, 2021 08:40
@pradyunsg
Copy link
Member Author

x-ref #8273 since that is still the main annoying part.

Copy link
Contributor

@puetzk puetzk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted (meant to comment on the relevant line)

tests/lib/test_lib.py Outdated Show resolved Hide resolved
@uranusjr
Copy link
Member

Maybe we could do --use-venv on Python 3.10 and get it in first for most stuff; IIRC only ~1% of the tests are currently incompatible with venv.

@pradyunsg
Copy link
Member Author

The problem isn't virtualenv -- there's only one failure test_pip_works_with_warnings_as_errors; and that's happening because we're importing distutils which has a warning on import now.

@pfmoore
Copy link
Member

pfmoore commented Jul 24, 2021

there's only one failure test_pip_works_with_warnings_as_errors

Hmm, how is ensurepip in cpython core passing the 3.10 test suite in that case? That test was, I believe, specifically added because the CPython test suite runs with warnings as errors...

@pradyunsg
Copy link
Member Author

Hmm, how is ensurepip in cpython core passing the 3.10 test suite in that case?

🤷

Well, I think I wanna skip it for this initial round of adding 3.10 testing -- if this is indeed a problem for CPython, we'd catch it there. If not, well, the users who see this on 3.10 can adapt -- they're doing a migration/upgrade already.

This is necessary since Python 3.10 has two digits in the minor version.
There is no clean way, that we know of so far, for fixing this on 3.10+.
@uranusjr
Copy link
Member

uranusjr commented Aug 6, 2021

Hmm, how is ensurepip in cpython core passing the 3.10 test suite in that case?

I don’t know why, but apparently pip install a wheel on 3.10 does not trigger any distutils warnings:

$ virtualenv --python python3.10 --no-pip ./x
...

$ ./x/bin/python -c 'import distutils'  # Triggers a warning as expected
<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives

$ ./x/bin/python -m ensurepip  # No warnings!
Looking in links: /tmp/tmpymqbilj5
Requirement already satisfied: setuptools in ./x/lib/python3.10/site-packages (57.0.0)
Processing /tmp/tmpymqbilj5/pip-21.1.3-py3-none-any.whl
Installing collected packages: pip
Successfully installed pip-21.1.3

$ ./x/bin/python -m pip install -U pip  # Also no warnings!
Requirement already satisfied: pip in ./x/lib/python3.10/site-packages (21.1.3)
Collecting pip
  Using cached pip-21.2.3-py3-none-any.whl (1.6 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 21.1.3
    Uninstalling pip-21.1.3:
      Successfully uninstalled pip-21.1.3
Successfully installed pip-21.2.3

Copy link
Member

@uranusjr uranusjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be fixed #10164 (comment)

@pfmoore
Copy link
Member

pfmoore commented Aug 6, 2021

I don’t know why, but apparently pip install a wheel on 3.10 does not trigger any distutils warnings

https://github.com/python/cpython/blob/main/Lib/ensurepip/__init__.py#L92

@pradyunsg pradyunsg requested a review from uranusjr August 6, 2021 14:56
@pytest.mark.skipif(
sys.version_info >= (3, 10),
reason="distutils is deprecated in 3.10+"
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was only added because the CPython test suite failed when packaging raised a deprecation warning (for legacy versions, IIRC). As ensurepip now forcibly silences deprecation warnings as part of the distutils removal, we could probably just drop this (after all, I don't think we should guarantee that pip runs warning-free as a general matter).

But it's no big deal either way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gonna remove in a follow up. :)

Copy link
Contributor

@puetzk puetzk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version regex looks good to me now.

@pradyunsg pradyunsg closed this Aug 6, 2021
@pradyunsg pradyunsg reopened this Aug 6, 2021
@uranusjr uranusjr merged commit c18bc16 into pypa:main Aug 7, 2021
@pradyunsg pradyunsg deleted the python-3.10 branch August 7, 2021 07:35
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants