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

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

Open
mgorny opened this issue Dec 17, 2022 · 10 comments
Open

Comments

@mgorny
Copy link

mgorny commented Dec 17, 2022

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
Copy link
Author

mgorny commented Dec 17, 2022

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
Copy link
Owner

lorien commented Dec 24, 2022

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

@lorien
Copy link
Owner

lorien commented Dec 24, 2022

@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
Copy link
Author

mgorny commented Dec 24, 2022

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
Copy link
Owner

lorien commented Dec 24, 2022

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
Copy link
Author

mgorny commented Dec 24, 2022

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

@lorien
Copy link
Owner

lorien commented Dec 27, 2022

There is a related discussion in python-multipart issues Kludex/python-multipart#16

@kloczek
Copy link
Contributor

kloczek commented Mar 15, 2024

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

Here is pytest output:
+ 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 <module>
    from test_server.structure import HttpHeaderStorage
test_server/__init__.py:2: in <module>
    from test_server.server import *  # pylint: disable=wildcard-import # noqa: F403
test_server/server.py:17: in <module>
    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 <module>
    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
Copy link
Owner

lorien commented Mar 15, 2024

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
Copy link
Owner

lorien commented Mar 16, 2024

Working on it in this pull request #31

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

No branches or pull requests

3 participants