Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make dependency on pillow optional #1801

Open
1 of 4 tasks
gsemet opened this issue Jan 16, 2024 · 4 comments · May be fixed by #1847
Open
1 of 4 tasks

Make dependency on pillow optional #1801

gsemet opened this issue Jan 16, 2024 · 4 comments · May be fixed by #1847

Comments

@gsemet
Copy link

gsemet commented Jan 16, 2024

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
Copy link

xr09 commented Feb 1, 2024

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.

@pebo1
Copy link

pebo1 commented Feb 7, 2024

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.

@pebo1
Copy link

pebo1 commented Feb 7, 2024

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.

@dmbonsall
Copy link

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.

@cilki cilki linked a pull request Mar 31, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants