abersheeran / a2wsgi

Convert WSGI app to ASGI app or ASGI app to WSGI app.
Apache License 2.0
226 stars 20 forks source link

a2wsgi needs typing_extensions on older Python versions #52

Closed encukou closed 4 months ago

encukou commented 6 months ago

Hello, Thank you for a2wsgi! I found a packaging issue on Python 3.10 and lower:

asgi_typing.py has:

if sys.version_info >= (3, 11):
    from typing import NotRequired
else:
    from typing_extensions import NotRequired

However, typing_extensions is not listed as a runtime requirement. If a2wsgi is installed without its test dependencies, it fails to import:

$ pip install a2wsgi
[...]
Successfully installed a2wsgi-1.10.4

$ python
Python 3.8.19 (default, Mar 20 2024, 00:00:00) 
[GCC 13.2.1 20240316 (Red Hat 13.2.1-7)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import a2wsgi
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../python3.8/site-packages/a2wsgi/__init__.py", line 1, in <module>
    from .asgi import ASGIMiddleware
  File ".../python3.8/site-packages/a2wsgi/asgi.py", line 9, in <module>
    from .asgi_typing import HTTPScope, ASGIApp, ReceiveEvent, SendEvent
  File ".../python3.8/site-packages/a2wsgi/asgi_typing.py", line 21, in <module>
    from typing_extensions import NotRequired
ModuleNotFoundError: No module named 'typing_extensions'
>>> 
abersheeran commented 5 months ago

Welcome PR

encukou commented 5 months ago

The PR is at: https://github.com/abersheeran/a2wsgi/pull/57