Skip to content

3.12 support #12003

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

Closed
1 task done
gaborbernat opened this issue Apr 27, 2023 · 5 comments · Fixed by #12019
Closed
1 task done

3.12 support #12003

gaborbernat opened this issue Apr 27, 2023 · 5 comments · Fixed by #12019
Labels
S: awaiting response Waiting for a response/more information

Comments

@gaborbernat
Copy link

gaborbernat commented Apr 27, 2023

Description

While trying to add 3.12 support to virtualenv noticed that pip depends on distutils:

 'Remainder of file ignored\n'
 'Traceback (most recent call last):\n'
 '  File "/tmp/pytest-of-runner/pytest-0/test_app_data_pinning0/bin/pip", line '
 '5, in <module>\n'
 '    from pip._internal.main import main\n'
 '  File '
 '"/tmp/pytest-of-runner/pytest-0/test_app_data_pinning0/lib/python3.12/site-packages/pip/_internal/main.py", '
 'line 13, in <module>\n'
 '    from pip._internal.cli.autocompletion import autocomplete\n'
 '  File '
 '"/tmp/pytest-of-runner/pytest-0/test_app_data_pinning0/lib/python3.12/site-packages/pip/_internal/cli/autocompletion.py", '
 'line 11, in <module>\n'
 '    from pip._internal.cli.main_parser import create_main_parser\n'
 '  File '
 '"/tmp/pytest-of-runner/pytest-0/test_app_data_pinning0/lib/python3.12/site-packages/pip/_internal/cli/main_parser.py", '
 'line 7, in <module>\n'
 '    from pip._internal.cli import cmdoptions\n'
 '  File '
 '"/tmp/pytest-of-runner/pytest-0/test_app_data_pinning0/lib/python3.12/site-packages/pip/_internal/cli/cmdoptions.py", '
 'line 19, in <module>\n'
 '    from distutils.util import strtobool\n'

pip version

latest

Python version

3.12

OS

any

How to Reproduce

Run pip on 3.12 no setuptools.

Code of Conduct

@gaborbernat gaborbernat added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Apr 27, 2023
@nedbat
Copy link

nedbat commented May 2, 2023

As of last night's 3.12 build, I get this error:

% .tox/anypy/bin/python -m pip install rich
ERROR: Exception:
Traceback (most recent call last):
  File "/Users/nedbatchelder/coverage/trunk/.tox/anypy/lib/python3.12/site-packages/pip/_internal/cli/base_command.py", line 160, in exc_logging_wrapper
    status = run_func(*args)
             ^^^^^^^^^^^^^^^
  File "/Users/nedbatchelder/coverage/trunk/.tox/anypy/lib/python3.12/site-packages/pip/_internal/cli/req_command.py", line 247, in wrapper
    return func(self, options, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nedbatchelder/coverage/trunk/.tox/anypy/lib/python3.12/site-packages/pip/_internal/commands/install.py", line 326, in run
    session = self.get_default_session(options)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nedbatchelder/coverage/trunk/.tox/anypy/lib/python3.12/site-packages/pip/_internal/cli/req_command.py", line 98, in get_default_session
    self._session = self.enter_context(self._build_session(options))
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nedbatchelder/coverage/trunk/.tox/anypy/lib/python3.12/site-packages/pip/_internal/cli/req_command.py", line 125, in _build_session
    session = PipSession(
              ^^^^^^^^^^^
  File "/Users/nedbatchelder/coverage/trunk/.tox/anypy/lib/python3.12/site-packages/pip/_internal/network/session.py", line 343, in __init__
    self.headers["User-Agent"] = user_agent()
                                 ^^^^^^^^^^^^
  File "/Users/nedbatchelder/coverage/trunk/.tox/anypy/lib/python3.12/site-packages/pip/_internal/network/session.py", line 175, in user_agent
    setuptools_dist = get_default_environment().get_distribution("setuptools")
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nedbatchelder/coverage/trunk/.tox/anypy/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_envs.py", line 188, in get_distribution
    return next(matches, None)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/nedbatchelder/coverage/trunk/.tox/anypy/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_envs.py", line 183, in <genexpr>
    matches = (
              ^
  File "/Users/nedbatchelder/coverage/trunk/.tox/anypy/lib/python3.12/site-packages/pip/_internal/metadata/base.py", line 612, in iter_all_distributions
    for dist in self._iter_distributions():
  File "/Users/nedbatchelder/coverage/trunk/.tox/anypy/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_envs.py", line 176, in _iter_distributions
    for dist in finder.find_eggs(location):
  File "/Users/nedbatchelder/coverage/trunk/.tox/anypy/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_envs.py", line 144, in find_eggs
    yield from self._find_eggs_in_dir(location)
  File "/Users/nedbatchelder/coverage/trunk/.tox/anypy/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_envs.py", line 111, in _find_eggs_in_dir
    from pip._vendor.pkg_resources import find_distributions
  File "/Users/nedbatchelder/coverage/trunk/.tox/anypy/lib/python3.12/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2164, in <module>
    register_finder(pkgutil.ImpImporter, find_on_path)
                    ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?

@pfmoore
Copy link
Member

pfmoore commented May 2, 2023

Is this with the latest release (23.1.2)? That's the release that added support for the new 3.12 build, anything older than that won't work with 3.12.

@pfmoore pfmoore added S: awaiting response Waiting for a response/more information and removed type: bug A confirmed bug or unintended behavior S: needs triage Issues/PRs that need to be triaged labels May 2, 2023
@pfmoore
Copy link
Member

pfmoore commented May 2, 2023

@gaborbernat The same comment is true for the original issue - strtobool is no longer imported from distutils in 3.12.

@nedbat
Copy link

nedbat commented May 2, 2023

Hmm, it looks like although i have pip pinned to 23.1.2, in my tox environment, I have 22.3.1. My bad, I have to untangle this.

@pradyunsg
Copy link
Member

There are no distutils imports in pip outside of those gated behind the use of the distutils metadata and location logic, which is not used on 3.12.

Updating the version of pip being used should resolve the failure mode you're seeing. I'm not sure if there's anything actionable on pip's end here.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
S: awaiting response Waiting for a response/more information
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants