openfoodfacts / openfoodfacts-python

🐍 Python package for Open Food Facts
https://openfoodfacts.github.io/openfoodfacts-python/
Other
316 stars 66 forks source link

pillow is not installed with the package #257

Open gitting opened 1 month ago

gitting commented 1 month ago

What

Runningpip install openfoodfacts results with the following in a fresh venv:

annotated-types==0.7.0
certifi==2024.7.4
charset-normalizer==3.3.2
idna==3.7
openfoodfacts==1.1.1
pydantic==2.8.2
pydantic_core==2.20.1
requests==2.32.3
tqdm==4.66.4
typing_extensions==4.12.2
urllib3==2.2.2

pillow is not in the list, hence attempts to use the API result in the following:

Traceback (most recent call last):
  File "/private/tmp/food/test.py", line 1, in <module>
    import openfoodfacts
  File "/private/tmp/food/.venv/lib/python3.12/site-packages/openfoodfacts/__init__.py", line 1, in <module>
    from .api import API
  File "/private/tmp/food/.venv/lib/python3.12/site-packages/openfoodfacts/api.py", line 6, in <module>
    from .utils import URLBuilder, http_session
  File "/private/tmp/food/.venv/lib/python3.12/site-packages/openfoodfacts/utils.py", line 354, in <module>
    ) -> Union[ImageDownloadItem, Image.Image, None]:

After pip install pillow the list looks as follows:

annotated-types==0.7.0
certifi==2024.7.4
charset-normalizer==3.3.2
idna==3.7
openfoodfacts==1.1.1
pillow==10.4.0
pydantic==2.8.2
pydantic_core==2.20.1
requests==2.32.3
tqdm==4.66.4
typing_extensions==4.12.2
urllib3==2.2.2

and the API works.

Steps to reproduce the behavior:

  1. python3 -m venv .venv
  2. source .venv/bin/activate
  3. pip install openfoodfacts
  4. Observe pillow is missing

Expected behavior

pillow should be installed as a required dependency.

Could it be because of the optional = True key set in this line? https://github.com/openfoodfacts/openfoodfacts-python/blob/8d1013a01c8fa674c1c84fd1729b73c621b5edd3/pyproject.toml#L26

Platform (Desktop, Mobile, Hunger Games)