pip icon indicating copy to clipboard operation
pip copied to clipboard

Upgrade vendored typing_extensions to 4.14.0

Open youknowone opened this issue 6 months ago • 5 comments

Description

The bug from typing_extensions affect pip installation.

Related bug report of typing_extensions: https://github.com/python/typing_extensions/issues/404

Which is fixed from 4.14.0

Expected behavior

No response

pip version

25.1.1

Python version

RustPython main

OS

Linux (Github actions Ubuntu image)

How to Reproduce

./rustpython --install-pip

Output

File "/home/runner/work/RustPython/RustPython/pylib/Lib/runpy.py", line 224, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/home/runner/work/RustPython/RustPython/pylib/Lib/runpy.py", line 94, in _run_module_code
    with _TempModule(mod_name) as temp_module, _ModifiedArgv0(fname):
  File "/home/runner/work/RustPython/RustPython/pylib/Lib/runpy.py", line 97, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/home/runner/work/RustPython/RustPython/pylib/Lib/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/tmp/tmp3a6kinnx/pip-25.1.1-py3-none-any.whl/pip/__main__.py", line 22, in <module>
  File "/tmp/tmp3a6kinnx/pip-25.1.1-py3-none-any.whl/pip/_internal/cli/main.py", line 10, in <module>
  File "/tmp/tmp3a6kinnx/pip-25.1.1-py3-none-any.whl/pip/_internal/cli/autocompletion.py", line 9, in <module>
  File "/tmp/tmp3a6kinnx/pip-25.1.1-py3-none-any.whl/pip/_internal/cli/main_parser.py", line 8, in <module>
  File "/tmp/tmp3a6kinnx/pip-25.1.1-py3-none-any.whl/pip/_internal/build_env.py", line 16, in <module>
  File "/tmp/tmp3a6kinnx/pip-25.1.1-py3-none-any.whl/pip/_internal/cli/spinners.py", line 9, in <module>
  File "/tmp/tmp3a6kinnx/pip-25.1.1-py3-none-any.whl/pip/_internal/utils/logging.py", line 29, in <module>
  File "/tmp/tmp3a6kinnx/pip-25.1.1-py3-none-any.whl/pip/_internal/utils/misc.py", line 44, in <module>
  File "/tmp/tmp3a6kinnx/pip-25.1.1-py3-none-any.whl/pip/_internal/utils/retry.py", line 8, in <module>
  File "/tmp/tmp3a6kinnx/pip-25.1.1-py3-none-any.whl/pip/_vendor/typing_extensions.py", line 1768, in __new__
  File "/tmp/tmp3a6kinnx/pip-25.1.1-py3-none-any.whl/pip/_vendor/typing_extensions.py", line 1613, in _set_default
AttributeError: attribute '__default__' of 'ParamSpec' objects is not writable
Traceback (most recent call last):
  File "/home/runner/work/RustPython/RustPython/pylib/Lib/runpy.py", line 197, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/runner/work/RustPython/RustPython/pylib/Lib/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/runner/work/RustPython/RustPython/pylib/Lib/ensurepip/__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
  File "/home/runner/work/RustPython/RustPython/pylib/Lib/ensurepip/__init__.py", line [26](https://github.com/RustPython/RustPython/actions/runs/15660508360/job/44117485825?pr=5740#step:16:27)3, in _main
    default_pip=args.default_pip,
  File "/home/runner/work/RustPython/RustPython/pylib/Lib/ensurepip/__init__.py", line 153, in _bootstrap
    with tempfile.TemporaryDirectory() as tmpdir:
  File "/home/runner/work/RustPython/RustPython/pylib/Lib/ensurepip/__init__.py", line 172, in _bootstrap
    return _run_pip([*args, "pip"], [os.fsdecode(tmp_wheel_path)])
  File "/home/runner/work/RustPython/RustPython/pylib/Lib/ensurepip/__init__.py", line 87, in _run_pip
    return subprocess.run(cmd, check=True).returncode
  File "/home/runner/work/RustPython/RustPython/pylib/Lib/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/home/runner/work/RustPython/RustPython/pylib/Lib/subprocess.py", line 572, in run
    output=stdout, stderr=stderr)

Code of Conduct

youknowone avatar Jun 15 '25 09:06 youknowone

This will be fixed as part of the routine updates of our vendored dependencies prior to the 25.2 release. I’m not entirely clear why it’s causing you issues now, as our normal build and release process for pip 25.1 worked fine. Is it something specific to rustpython?

pfmoore avatar Jun 15 '25 12:06 pfmoore

typing_extensions checks if typing.ParamSpec exists:

# 3.10+
if hasattr(typing, 'ParamSpec'):

CPython run the if block. RustPython goes to else block due to lack of typing.ParamSpec. That triggers

  File "/tmp/tmp3a6kinnx/pip-25.1.1-py3-none-any.whl/pip/_vendor/typing_extensions.py", line 1768, in __new__

hmm, now this is looking like a weird bug. Running hasattr(typing, 'ParamSpec') in recent version of RustPython also returns True

youknowone avatar Jun 15 '25 13:06 youknowone

Better than updating it, why don't we try and remove it as a runtime and vendored dependency?

Taking a quick look, pip only needs to be updated in a few places, I can raise a PR to fix that, and only one of our vendored dependencies is using it at runtime, rich, I will take a look and see if I can raise a PR over there as well.

notatallshaw avatar Jun 15 '25 14:06 notatallshaw

OK, so this looks like it's a temporary problem caused by RustPython's behaviour differing from CPython's.

We'll get the new typing_extensions in due course, so there's nothing more to do here.

Better than updating it, why don't we try and remove it as a runtime and vendored dependency?

Your post arrived as I was typing the above. If we can remove the dependency, I'm happy with that as an alternative.

Either way, @youknowone, this should be fixed in pip 25.2.

pfmoore avatar Jun 15 '25 14:06 pfmoore

Thank you so much!

youknowone avatar Jun 16 '25 00:06 youknowone

This was fixed by https://github.com/pypa/pip/pull/13439, and when rich does it's next release we can look to remove it as a runtime dependency altogether.

notatallshaw avatar Jun 27 '25 15:06 notatallshaw