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

[BUG] Pip fails with Python 3.13 Free Threading #4415

Closed
FabriceSalvaire opened this issue Jun 5, 2024 · 8 comments
Closed

[BUG] Pip fails with Python 3.13 Free Threading #4415

FabriceSalvaire opened this issue Jun 5, 2024 · 8 comments
Labels
bug Needs Triage Issues that need to be evaluated for severity and status. Waiting User Feedback

Comments

@FabriceSalvaire
Copy link

FabriceSalvaire commented Jun 5, 2024

setuptools version

70.0.0

Python version

3.13 ft

OS

Fedora 39

Additional environment information

pypa/pip#12747

Description

Pip fails to install a package (Pillow) with Python 3.13 Free Threading.
Pillow can be installed from source using python3.13t setup.py install.

I think this is annoying to perform Python 3.13 Free Threading crash test...

Expected behavior

...

How to Reproduce

  1. Try to install a package with pip...

Output

>pip install --upgrade pip
Requirement already satisfied: pip in /opt/python-virtual-env/free-thread/lib64/python3.13/site-packages (23.2.1)
Collecting pip
Obtaining dependency information for pip from https://files.pythonhosted.org/packages/8a/6a/19e9fe04fca059ccf770861c7d5721ab4c2aebc539889e97c7977528a53b/pip-24.0-py3-none-any.whl.metadata
Downloading pip-24.0-py3-none-any.whl.metadata (3.6 kB)
Downloading pip-24.0-py3-none-any.whl (2.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 12.0 MB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 23.2.1
Uninstalling pip-23.2.1:
Successfully uninstalled pip-23.2.1
Successfully installed pip-24.0

>pip install setuptools
Collecting setuptools
Using cached setuptools-70.0.0-py3-none-any.whl.metadata (5.9 kB)
Using cached setuptools-70.0.0-py3-none-any.whl (863 kB)
Installing collected packages: setuptools
Successfully installed setuptools-70.0.0
>pip install pillow
Collecting pillow
Downloading pillow-10.3.0.tar.gz (46.6 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 46.6/46.6 MB 14.3 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [21 lines of output]
Traceback (most recent call last):
File "/opt/python-virtual-env/free-thread/lib64/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
~~~~^^
File "/opt/python-virtual-env/free-thread/lib64/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/python-virtual-env/free-thread/lib64/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
File "/tmp/pip-build-env-cpz4twfh/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-cpz4twfh/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
self.run_setup()
~~~~~~~~~~~~~~^^
File "/tmp/pip-build-env-cpz4twfh/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 311, in run_setup
exec(code, locals())
~~~~^^^^^^^^^^^^^^^^
File "<string>", line 33, in <module>
File "<string>", line 27, in get_version
KeyError: '__version__'
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
@FabriceSalvaire FabriceSalvaire added bug Needs Triage Issues that need to be evaluated for severity and status. labels Jun 5, 2024
@abravalheri
Copy link
Contributor

abravalheri commented Jun 5, 2024

Hi @FabriceSalvaire , by looking at the stacktrace it seems that the code is crashing when running the following code that belongs to the setup.py of Pillow:

def get_version():
    version_file = "src/PIL/_version.py"
    with open(version_file, encoding="utf-8") as f:
        exec(compile(f.read(), version_file, "exec"))
    return locals()["__version__"]

i.e., after executing the src/PIL/_version.py file, no __version__ attribute is set.

This seems like it is a problem with that specific setup.py? Maybe it is worth checking that particular implementation?

Or maybe Python 3.13 has a problem with an exec inside of an exec?

Anotgwr possibility is that this version of Python does not like the from __future__ import annotations that is in the beginning of the file being exec-ed?

@lysnikolaou
Copy link

This was fixed on the Pillow side here.

@abravalheri
Copy link
Contributor

abravalheri commented Jun 7, 2024

This was fixed on the Pillow side here.

Still it sounds like a limitation of that particular implementation of Python... Apparently it cannot handle and exec inside of another exec? Or is my interpretation wrong?

(It might also be the __future__ annotation being used inside of an exec...)

@FabriceSalvaire
Copy link
Author

Ah ya it is Pillow, that works

pip install git+https://github.com/python-pillow/Pillow

@FabriceSalvaire
Copy link
Author

@abravalheri It is due to PEP 667 locals
python/cpython#118888 (comment)

@FabriceSalvaire
Copy link
Author

I close since we have the explanation.

@jsbueno
Copy link

jsbueno commented Jun 10, 2024

this also failed me o a custom Python 3.12 build - both for pillow 10.3.0 and pillow 10.3.0 - 10.4.0-dev0 from the pip install from git command line above worked.

@bje-
Copy link

bje- commented Jun 12, 2024

Will a new version of pillow be pushed into PyPI soon that fixes this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Needs Triage Issues that need to be evaluated for severity and status. Waiting User Feedback
Projects
None yet
Development

No branches or pull requests

5 participants