lorien / test_server

Server to test HTTP clients
MIT License
4 stars 3 forks source link

multipart requirement conflicts with python-multipart used by starlette #27

Open mgorny opened 1 year ago

mgorny commented 1 year ago

The recently introduced dependency on multipart made it impossible to package the new version on Gentoo Linux since we already package python-multipart which uses the same package name (sic!) and is required by the more popular starlette package.

mgorny commented 1 year ago

Oh, I've just noticed that we don't actually need this package anymore, so please feel free to disregard the problem, though some of other test_server users may hit a similar problem. Unfortunately, this is just a proof of how rotten pypi is at the core.

lorien commented 1 year ago

Me reading your first message: wow, somebody uses my package Me reading your second message: or maybe not :D

lorien commented 1 year ago

@mgorny I do not get what is the problem. There is "multipart" and "python-multipart' packages in pypi. Why it is bad? Except the fact that it causes some problems in buildings packages for gentoo.

Regarding "multipart" package. I'll take a look on "python-multipart", maybe I should switch to it. The only reason I have introduced multipart dependency is that builtin module cgi (which contains things to parse multipart data) will be removed in python 3.13

mgorny commented 1 year ago

The problem is that one installs as multipart whereas the other installs as multipart.py. Therefore, if you end up having both installed, only one of them will be importable:

>>> import multipart
>>> multipart
<module 'multipart' from '/tmp/.venv/lib/python3.11/site-packages/multipart/__init__.py'>

In other words, if something depends on python-multipart, you'd end up using that instead because it will be impossible to import multipart.py without resorting to awful hacks.

lorien commented 1 year ago

I see. Both pypi packages provide their API as "multipart" python package making impossible to coexist these packages in same environmet like python virtualenv or gentoo default python environment. Maybe I should vendor source code of one of these multipart packages into test_server package to avoid being a participant of package hell party.

mgorny commented 1 year ago

I'm afraid that just replaces one hell with another (vendoring hell).

lorien commented 1 year ago

There is a related discussion in python-multipart issues https://github.com/andrew-d/python-multipart/issues/16

kloczek commented 8 months ago

Gentle ping .. Any update? 🤔 Seems I've git the same issue

Here is pytest output: ```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-test-server-0.0.43-2.fc36.x86_64/usr/lib64/python3.9/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-test-server-0.0.43-2.fc36.x 86_64/usr/lib/python3.9/site-packages + /usr/bin/pytest -ra -m 'not network' ============================= test session starts ============================== platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0 rootdir: /home/tkloczko/rpmbuild/BUILD/test_server-0.0.43 configfile: pyproject.toml testpaths: tests collected 0 items / 2 errors ==================================== ERRORS ==================================== _______________ ERROR collecting tests/test_httpheaderstorage.py _______________ ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/test_server-0.0.43/tests/test_httpheaderstorage.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: /usr/lib64/python3.9/importlib/__init__.py:127: in import_module return _bootstrap._gcd_import(name[level:], package, level) tests/test_httpheaderstorage.py:3: in from test_server.structure import HttpHeaderStorage test_server/__init__.py:2: in from test_server.server import * # pylint: disable=wildcard-import # noqa: F403 test_server/server.py:17: in from multipart import parse_form_data E ImportError: cannot import name 'parse_form_data' from 'multipart' (/usr/lib/python3.9/site-packages/multipart/__init__.py) ____________________ ERROR collecting tests/test_server.py _____________________ ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/test_server-0.0.43/tests/test_server.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: /usr/lib64/python3.9/importlib/__init__.py:127: in import_module return _bootstrap._gcd_import(name[level:], package, level) tests/test_server.py:11: in from urllib3.response import BaseHTTPResponse E ImportError: cannot import name 'BaseHTTPResponse' from 'urllib3.response' (/usr/lib/python3.9/site-packages/urllib3/response.py) =========================== short test summary info ============================ ERROR tests/test_httpheaderstorage.py ERROR tests/test_server.py !!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!! ============================== 2 errors in 0.23s =============================== ```
lorien commented 8 months ago

I am lookint into this https://github.com/litestar-org/litestar/blob/main/litestar/_multipart.py I will copy-paste it into test_server package. It is already annotated with types and I think it is well tested because it is a part of production web server framework.

lorien commented 8 months ago

Working on it in this pull request https://github.com/lorien/test_server/pull/31