Open gsemet opened 5 months ago
I'll add even another reason to replace Pillow with something else or at least make it optional, space (and network) optimization.
In a project we recently added the Jira package as a dependency, the Docker image grew a few MB and made me a bit curious how only one lib could add more than 10 MB.
Pillow (9.4 MiB) and PIL (6.4 MiB) are "heavy" dependencies in comparison with the Jira library (540 KiB). I know we're talking roughly 16 MB, but still, it adds up.
The PIL library is only being used in one line of code in the whole project, here [1] for guessing the mimetype of the avatar image.
To get a better picture I did a quick experiment using the python:3.11-alpine image and then installing jira and pillow libraries separatedly.
python 3.11-alpine f5c01bd13f32 6 weeks ago 52.5MB
python-with-pillow 3.11-alpine 0df0d8893ede 3 minutes ago 84.9MB
python-with-jira 3.11-alpine fc04344867e0 3 minutes ago 91.8MB
I estimate a "pillow-less" python-with-jira image could be around 60MB.
I would like to add another reason.
Using PIL/Pillow on AWS Lambda is kind of pain. I can't build my Application in the CI/CD Pipeline because AWS Lambda can't handle PIL/Pillow when build on Alpine. This is mainly because of the c libs used by PIL/Pillow.
Now there are just those solutions: 1) Using a special Container and build my application with aws sam cli (adding the container as another layer of potentially more hazzle) 2) Using a aws lambda compatible container on build time instead of the neat little alpine container. -> Conatiner is 6 times bigger than alpine
Both solutions are overhead, especially if you take into consideration that I simply don't need the PIL/Pillow functionality in the Jira Lib.
Pillow was added in https://github.com/pycontribs/jira/pull/1680 because of this issue https://github.com/pycontribs/jira/issues/1557 @ABizzinotto just have a look at this thread please.
I think Pillow is a way to complex and large dependency for the task in your MR.
I agree with others that pillow is a bit overkill for this situation. According to PEP 594 which removes the imghdr
lib, the recommended replacements are filetype, puremagic, and python-magic.
Of these, python-magic
requires libmagic
which may cause issues for cross-platform support. puremagic
and filetype
look to be lightweight and not require any external dependencies. The example code in filetype
looks like it may be a good drop in replacement for what imghdr
was being used for. I would suggest going with filetype
.
Bug summary
Please provide a way to install and use your package without
pillow
which is really a nightmare to package in pyinstaller or using shiv. You can useextra
to have this dependencies optional and try/except the import only when really needed.thanks
Is there an existing issue for this?
Jira Instance type
Jira Cloud (Hosted by Atlassian)
Jira instance version
No response
jira-python version
main
Python Interpreter version
3.8
Which operating systems have you used?
Reproduction steps
Stack trace
Expected behaviour
jira can be installed without pillow. only to use the image related feature this dependency is needed
Additional Context
No response