dropbox / dropbox-sdk-python

The Official Dropbox API V2 SDK for Python
https://www.dropbox.com/developers
MIT License
930 stars 318 forks source link

Add Python 3.12 support #483

Closed sarahboyce closed 3 months ago

sarahboyce commented 9 months ago

Describe the bug This package cannot be used on Python 3.12. Traceback:

from dropbox.files import FileMetadata
.tox/py3.12-django5.0/lib/python3.12/site-packages/dropbox/__init__.py:3: in <module>
    from dropbox.dropbox_client import (  # noqa: F[40](https://github.com/jschneier/django-storages/actions/runs/6684029520/job/18170161117#step:5:41)1 # pylint: disable=unused-import
.tox/py3.12-django5.0/lib/python3.12/site-packages/dropbox/dropbox_client.py:[43](https://github.com/jschneier/django-storages/actions/runs/6684029520/job/18170161117#step:5:44): in <module>
    from dropbox.session import (
.tox/py3.12-django5.0/lib/python3.12/site-packages/dropbox/session.py:1: in <module>
    import pkg_resources
E   ModuleNotFoundError: No module named 'pkg_resources'

This appears to be caused by the following deprecation:

Ref: Python 3.12 release notes: https://docs.python.org/3/whatsnew/3.12.html

I hope that's enough context 👍

greg-db commented 9 months ago

Thanks for the report! I'll ask the team to fix that up.

rianhunter commented 7 months ago

Bump for this issue. Just add setuptools to install_requires on this line:

https://github.com/dropbox/dropbox-sdk-python/blob/487793dff3c5a8a3a76010799dc4803cabdb70f3/setup.py#L27C4-L27C4

Or alternatively use the importlib.resources module if the pkg_resources module does not exist. pkg_resources is deprecated in newer versions of Python.

rianhunter commented 7 months ago

If it will makes things faster, I can provide a PR that fixes this issue. Just LMK

greg-db commented 7 months ago

@rianhunter Thanks! We welcome PRs, but I can't promise a timeline for when the team would be able to review/test/release it.

maxbelanger commented 3 months ago

v12.0.0 no longer packages a resource file, so it no longer needs pkg_resources at runtime. Can you give that a try?

rianhunter commented 3 months ago

Tried it with Python trunk:

$ env/bin/python
Python 3.14.0a0 (heads/main:fbe6a0988f, May 14 2024, 15:17:09) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dropbox
>>> dropbox.__version__
'12.0.0'
>>>

Imports just fine now. Feel free to close.