pycontribs/jira

Make dependency on pillow optional

gsemet opened this issue · 4 comments

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 use extra to have this dependencies optional and try/except the import only when really needed.

thanks

Is there an existing issue for this?

  • I have searched the existing issues

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?

  • Linux
  • macOS
  • Windows

Reproduction steps

pillow is hard to package in shiv (zipapp).

Stack trace

n/a

Expected behaviour

jira can be installed without pillow. only to use the image related feature this dependency is needed

Additional Context

No response

xr09 commented

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.

Screenshot_20240201_182840

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.

[1]

return mimetypes.guess_type("f." + Image.open(buff).format)[0]

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 #1680 because of this issue #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.