cookiecutter / cookiecutter-django

Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.
https://cookiecutter-django.readthedocs.io
BSD 3-Clause "New" or "Revised" License
11.76k stars 2.83k forks source link

Removing pillow dependency? revisited #5183

Closed picturedots closed 1 day ago

picturedots commented 2 days ago

This question was asked in 2017 -- Remove dependency on Pillow? #1286 -- but it seems worth bringing up again.

While reviewing my dependencies from my cookie-cutter generated Django project, I noticed the sizable and dependency on Pillow. As far as I can tell, this dependency is completely unused. Removing the Pillow dependency shrunk my docker container by 20 MB, significant to be worthwhile in my opinion.

I believe that Pillow was originally added here https://github.com/cookiecutter/cookiecutter-django/commit/988b4f8a46c73e5ae45b77aa00abed43a3d295a1 in 2013 and has been the requirements ever since.

luzfcb commented 2 days ago

@picturedots Thanks for the comment.

I don't know if @browniebroke agrees with me, but cookiecutter-django is a highly opinionated project. Historically we have provided Pillow, because it has several non-Python dependencies that can be (or were) difficult to remember/install for each of the supported operating systems and also because Pillow will in most cases be a dependency that will be added later in projects . Furthermore, removing Pillow from the generated project is trivial.

I vote to keep Pillow even though it is not initially used directly by the generated project.

foarsitter commented 2 days ago

Pillow is an dependency of Django itself, otherwise the ImageField cannot be used: https://github.com/django/django/blob/289f48c71b0fdd058defb29879368897fb837021/django/db/models/fields/files.py#L435

picturedots commented 1 day ago

Thanks. I'm glad I asked...now there's a bit more info for someone else who is interested in optimizing their docker containers.

I can confirm that for anyone not using ImageField that simply removing the line from requirements is all that is required to remove.

browniebroke commented 1 day ago

Agree with what was said before. While being optional/not needed in the fields used by the generated project, I find that in practice I always end up using an ImageField so having this work out of the box is very convenient 😄