minio / minio-py

MinIO Client SDK for Python
https://docs.min.io/docs/python-client-quickstart-guide.html
Apache License 2.0
822 stars 318 forks source link

minio 7.2.1 requires urllib3>=2.0 #1378

Closed ydc-0 closed 8 months ago

ydc-0 commented 8 months ago

Issue

To reproduce

pip install urllib3\<2.0
pip install minio==7.2.1
python -c 'import minio'

Failure Logs

➜  ~ pip install urllib3\<2.0
...
Successfully installed urllib3-1.26.18

➜  ~ pip install minio 
...
Successfully installed argon2-cffi-23.1.0 argon2-cffi-bindings-21.2.0 minio-7.2.1 pycryptodome-3.19.0

[notice] A new release of pip is available: 23.3.1 -> 23.3.2
[notice] To update, run: pip install --upgrade pip

➜  ~ python -c 'import minio'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "***/.pyenv/pyenv/versions/3.11.4/lib/python3.11/site-packages/minio/__init__.py", line 41, in <module>
    from .api import Minio
  File "***/.pyenv/pyenv/versions/3.11.4/lib/python3.11/site-packages/minio/api.py", line 44, in <module>
    from urllib3.response import BaseHTTPResponse
ImportError: cannot import name 'BaseHTTPResponse' from 'urllib3.response' (***/.pyenv/pyenv/versions/3.11.4/lib/python3.11/site-packages/urllib3/response.py)
balamurugana commented 8 months ago

Feel free to send a PR

ydc-0 commented 8 months ago

@balamurugana Do you prefer to add urllib3>2.0 to install_requires or make minio compatible with urllib 1.x?

balamurugana commented 8 months ago

@balamurugana Do you prefer to add urllib3>2.0 to install_requires or make minio compatible with urllib 1.x?

@ydc-0 urllib3>2.0 to install_requires

mwagnurr commented 8 months ago

7.2.0 was still working without issues and just now our pipelines are breaking due to these urllib3 errors. I don't understand why this breaking change was introduced with a patch version in https://github.com/minio/minio-py/releases/tag/7.2.1

If I'm not missing something then just adding urllib3>=2.0 to install_requires will not change the fact that this is a breaking change, which is why I would suggest that the changes in 7.2.1 are reverted and instead released with a proper major version increase

balamurugana commented 8 months ago

What is the error you are getting?

anehx commented 8 months ago

We're having this issue as well. I'd really suggest that we add support for urllib 1 and 2 instead of forcing the v2 version just because of typing..

I'll try to find the time to submit a PR for this.

anehx commented 8 months ago

I investigated a little further: The only issue is the import of BaseHTTPResponse which minio uses for typing.

This class was added in urllib3 v2 and does not exist in v1. IMO we have multiple options to resolve this:

  1. We add urllib3>=2 as dependency in install_requires (as mentioned here) - this would force all applications using minio in combination with urllib3 v1 to downgrade to version 7.2.0 just because of typing.
  2. We use try / catch to import HTTPResponse instead of BaseHTTPResponse if the app uses version 1 of urllib3. This would work, but we'd tell the typing system that HTTPResponse is the same as BaseHTTPResponse which is simply not true.
  3. We import HTTPResponse and use that in our typing.

What do you think is the way to go @balamurugana @mwagnurr @ydc-0 ?

balamurugana commented 8 months ago

@anehx I suggest to use urllib3>=2 i.e. no change. urllib3 v1 is in maintenance mode and it won't get any new feature. Users of urllib3 v1 and don't want to upgrade to urllib3 v2 could use minio-py v7.2.0

ydc-0 commented 8 months ago

@anehx In fact, I'm still using minio==7.2.0 in my project, because there are other packages that require urllib3<2.

BTW, pip install minio urllib3<2 will still install minio==7.2.1, must add minio!=7.2.1 or minio<=7.2.0 to requirements.txt when using urllib3<2

✗ pip install minio urllib3<2
    Uninstalling minio-7.2.2:
      Successfully uninstalled minio-7.2.2
Successfully installed minio-7.2.1 urllib3-1.26.18   # do not work

✗ pip install minio!=7.2.1 urllib3\<2
Successfully installed minio-7.2.0

✗ pip install --upgrade minio urllib3\>2
Successfully installed minio-7.2.2 urllib3-2.1.0
ydc-0 commented 8 months ago

@balamurugana Is it possible to avoid pip install minio==7.2.1 by default when there are urllib3<2? May yank the version 7.2.1? https://peps.python.org/pep-0592/

If pip install minio urllib3<2 could install minio==7.2.0, it would help others to not have a hard limit of minio.