posit-dev / great-tables

Make awesome display tables using Python.
https://posit-dev.github.io/great-tables/
MIT License
1.81k stars 60 forks source link

Missing `setuptools` dependency #270

Closed daureg closed 5 months ago

daureg commented 6 months ago

Prework

Description

great tables imports pkg_resources but doesn't list setuptools as dependency.

Reproducible example

Using uv to create the virtual environment because it doesn't include setuptools by default.

uv venv && source .venv/bin/activate && uv pip install great_tables && python3 -c "import great_tables"

Using Python 3.10.13 interpreter at: /home/glefalher/.pyenv/versions/3.10.13/bin/python3
Creating virtualenv at: .venv
Activate with: source .venv/bin/activate
Resolved 17 packages in 16ms
Installed 17 packages in 27ms
 + babel==2.14.0
 + commonmark==0.9.1
 + great-tables==0.4.0
 + htmltools==0.5.1
 + importlib-metadata==7.1.0
 + mizani==0.11.1
 + numpy==1.26.4
 + packaging==24.0
 + pandas==2.2.1
 + python-dateutil==2.9.0.post0
 + pytz==2024.1
 + scipy==1.13.0
 + six==1.16.0
 + typing-extensions==4.11.0
 + tzdata==2024.1
 + webcolors==1.13
 + zipp==3.18.1
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/glefalher/nwork/gtpkg2/.venv/lib/python3.10/site-packages/great_tables/__init__.py", line 10, in <module>
    from .gt import GT
  File "/home/glefalher/nwork/gtpkg2/.venv/lib/python3.10/site-packages/great_tables/gt.py", line 15, in <module>
    from great_tables._formats import (
  File "/home/glefalher/nwork/gtpkg2/.venv/lib/python3.10/site-packages/great_tables/_formats.py", line 20, in <module>
    from ._locale import _get_locales_data, _get_default_locales_data, _get_currencies_data
  File "/home/glefalher/nwork/gtpkg2/.venv/lib/python3.10/site-packages/great_tables/_locale.py", line 4, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

Expected result

great_tables should be importable

Development environment

Additional context

The same example works when using python to create the virtual enviroment

python3 -m venv venv && source venv/bin/activate && python3 -m pip install -U great_tables && python3 -c "import great_tables"

According to the doc:

Use of pkg_resources is deprecated in favor of :mod:importlib.resources, :mod:importlib.metadata and their backports (:pypi:importlib_resources, :pypi:importlib_metadata).

samuel-odinware commented 6 months ago

I am getting the same ModuleNotFoundError: No module named 'pkg_resources' using Poetry.

machow commented 5 months ago

I noticed hit this while working on #261, and replaced setuptools code with importlib_resources. Should be resolved there!

rich-iannone commented 5 months ago

Fixed by https://github.com/posit-dev/great-tables/pull/261.