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

Update setup.py to accommodate Python3.13.0 #2409

Closed
wants to merge 1 commit into from

Conversation

Shonas301
Copy link

Changes made

  • Update setup.py to pass in a local dictionary to exec to capture the locals() in _version.py for package version reporting.

Motivation

  • Python3.13.0 enforces stricter safety standards on locals() with PEP 667 (see here)

  • This causes the following error upon attempting to install with python3.13 -m pip install openai-whisper:

Collecting openai-whisper
  Using cached openai-whisper-20240930.tar.gz (800 kB)
  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
  ╰─> [25 lines of output]
      <string>:5: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
      Traceback (most recent call last):
        File "/Users/jasonshipp/.pyenv/versions/3.13.0/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
          ~~~~^^
        File "/Users/jasonshipp/.pyenv/versions/3.13.0/lib/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 "/Users/jasonshipp/.pyenv/versions/3.13.0/lib/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 "/private/var/folders/hk/8xz63_l16zb9snz57jx9hqgr0000gn/T/pip-build-env-l_19mrvs/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 332, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/hk/8xz63_l16zb9snz57jx9hqgr0000gn/T/pip-build-env-l_19mrvs/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 302, in _get_build_requires
          self.run_setup()
          ~~~~~~~~~~~~~~^^
        File "/private/var/folders/hk/8xz63_l16zb9snz57jx9hqgr0000gn/T/pip-build-env-l_19mrvs/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 516, in run_setup
          super().run_setup(setup_script=setup_script)
          ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/hk/8xz63_l16zb9snz57jx9hqgr0000gn/T/pip-build-env-l_19mrvs/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 318, in run_setup
          exec(code, locals())
          ~~~~^^^^^^^^^^^^^^^^
        File "<string>", line 21, in <module>
        File "<string>", line 11, in read_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

EXTRA NOTES

  • This does not enable openai-whisper to be pip installed with Python3.13, due to a dependency on the numba library. This issue and missing dependency can be tracked here

*Changes made*

- Update `setup.py` to pass in a local dictionary to `exec` to capture
  the `locals()` in `_version.py` for package version reporting.

*Motivation*

- `Python3.13.0` enforces stricter safety standards on `locals()` with
  PEP 667 (see [here](python/cpython#118888 (comment)))

- This causes the following error upon attempting to install with
  `python3.13 -m pip install openai-whisper`:

```bash
Collecting openai-whisper
  Using cached openai-whisper-20240930.tar.gz (800 kB)
  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
  ╰─> [25 lines of output]
      <string>:5: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
      Traceback (most recent call last):
        File "/Users/jasonshipp/.pyenv/versions/3.13.0/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
          ~~~~^^
        File "/Users/jasonshipp/.pyenv/versions/3.13.0/lib/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 "/Users/jasonshipp/.pyenv/versions/3.13.0/lib/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 "/private/var/folders/hk/8xz63_l16zb9snz57jx9hqgr0000gn/T/pip-build-env-l_19mrvs/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 332, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/hk/8xz63_l16zb9snz57jx9hqgr0000gn/T/pip-build-env-l_19mrvs/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 302, in _get_build_requires
          self.run_setup()
          ~~~~~~~~~~~~~~^^
        File "/private/var/folders/hk/8xz63_l16zb9snz57jx9hqgr0000gn/T/pip-build-env-l_19mrvs/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 516, in run_setup
          super().run_setup(setup_script=setup_script)
          ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/hk/8xz63_l16zb9snz57jx9hqgr0000gn/T/pip-build-env-l_19mrvs/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 318, in run_setup
          exec(code, locals())
          ~~~~^^^^^^^^^^^^^^^^
        File "<string>", line 21, in <module>
        File "<string>", line 11, in read_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
```

*EXTRA NOTES*

- This does not enable `openai-whisper` to be pip installed with
  `Python3.13`, due to a dependency on the `numba` library. This issue
  and missing dependency can be tracked [here](numba/numba#9413)
@cclauss
Copy link
Contributor

cclauss commented Nov 12, 2024

Would it be a more intuitive and durable solution to replace the deprecated pkg_resources with packaging?

The error message contained

DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html

Use of pkg_resources is deprecated in favor of importlib.resources, importlib.metadata and their backports (importlib_resources, importlib_metadata). Some useful APIs are also provided by packaging (e.g. requirements and version parsing). Users should refrain from new usage of pkg_resources and should work to port to importlib-based solutions.

@cozzbie
Copy link

cozzbie commented Dec 25, 2024

Any luck with this?

@cav71
Copy link

cav71 commented Dec 28, 2024

Yes, #2435 merge would be great! But there's an issue with numba <-> llvmlite

@yakovlevway
Copy link

Problem is on Python version 3.13.1

Collecting openai-whisper
  Using cached openai-whisper-20240930.tar.gz (800 kB)
  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
  ╰─> [25 lines of output]
      <string>:5: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
      Traceback (most recent call last):
        File "C:\Python313\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
          ~~~~^^
        File "C:\Python313\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ~~~~^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Python313\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
        File "C:\Users\Anton\AppData\Local\Temp\pip-build-env-jkd8x0ic\overlay\Lib\site-packages\setuptools\build_meta.py", line 334, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Anton\AppData\Local\Temp\pip-build-env-jkd8x0ic\overlay\Lib\site-packages\setuptools\build_meta.py", line 304, in _get_build_requires
          self.run_setup()
          ~~~~~~~~~~~~~~^^
        File "C:\Users\Anton\AppData\Local\Temp\pip-build-env-jkd8x0ic\overlay\Lib\site-packages\setuptools\build_meta.py", line 522, in run_setup
          super().run_setup(setup_script=setup_script)
          ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Anton\AppData\Local\Temp\pip-build-env-jkd8x0ic\overlay\Lib\site-packages\setuptools\build_meta.py", line 320, in run_setup
          exec(code, locals())
          ~~~~^^^^^^^^^^^^^^^^
        File "<string>", line 21, in <module>
        File "<string>", line 11, in read_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.

@cclauss
Copy link
Contributor

cclauss commented Jan 3, 2025

@yakovlevway Does this merely repeat what is in the commit message above or is it different?

@cav71
Copy link

cav71 commented Jan 3, 2025

@yakovlevway Does this merely repeat what is in the commit message above or is it different?

This is a different error, it looks it is missing __version__ somewhere in the source files.

        File "<string>", line 11, in read_version
      KeyError: '__version__'

@cclauss
Copy link
Contributor

cclauss commented Jan 4, 2025

#2435 (comment) might still be a problem although their release candidates now seem to support Python 3.13... https://pypi.org/project/numba/0.60.0/#history

@jongwook
Copy link
Collaborator

jongwook commented Jan 4, 2025

thanks all for reporting compatibility issues with 3.13. this PR was closed automatically by #2435. Hoping their upcoming release can fix the remaining compat issue!

@cclauss
Copy link
Contributor

cclauss commented Jan 4, 2025

Nice progress… It would be great to have some pull requests that contain tests that fail because of the remaining compatibility issues. When they pass we would have confidence to make the next release. These tests would also help to avoid future regressions.

@cclauss
Copy link
Contributor

cclauss commented Jan 4, 2025

Python 3.13 is blocked by both numba and triton.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants