Skip to content

chore: Optional pillow requirement#135

Merged
vvatelot merged 3 commits into
cnumr:mainfrom
Quentium-Forks:optional-pillow
May 22, 2026
Merged

chore: Optional pillow requirement#135
vvatelot merged 3 commits into
cnumr:mainfrom
Quentium-Forks:optional-pillow

Conversation

@QuentiumYT
Copy link
Copy Markdown
Contributor

When installing EcoIndex scrapper in a Docker image, it needs plenty of dependencies. Why? Just because pillow needs to be build from source as it is a required dependency.
Since installing sudo apt-get install libtiff5-dev libjpeg8-dev libopenjp2-7-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk libharfbuzz-dev libfribidi-dev libxcb1-dev takes a while and bloat the Dockerfile, this is not so interesting.
https://pillow.readthedocs.io/en/stable/installation/building-from-source.html

EcoIndex scrapper only uses pillow to generate a webp version if the user asks for it (which is probably less than 1% of all users). I suggest moving webp to an optional dependency.

Users can now install this little extra with pip install ecoindex-scraper[webp], preventing a long install with compile time. A nice throw is shown for users that needs a webp screenshot and haven't installed the webp extra :)

Thanks for your review, I needed it for a project and hopefully you can make a release soon!

@QuentiumYT
Copy link
Copy Markdown
Contributor Author

Will regen poetry lock tomorrow for CI

@vvatelot
Copy link
Copy Markdown
Member

Hello @QuentiumYT, thanks for this PR ! :) Greatly appreciate it !
I was not aware of this, and this is really a good point. Do you have a docker image size diff before/after change ?
I suggest you add a line in the installation guide to explain hox to install for people who need to make screenshot.

@QuentiumYT
Copy link
Copy Markdown
Contributor Author

Hello :) it should be good now. I can't tell the size difference (didn't built it again) but we need the whole build-essential with cmake & gcc etc which is growing the size by a lot ^^'

Comment thread components/ecoindex/scraper/scrap.py Outdated
try:
await convert_screenshot_to_webp(self.screenshot)
except ImportError:
print("WebP conversion skipped: Pillow library is not installed.")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 suggestion(non-blocking): Instead of basicaly printing the message, maybe it is better to log it using loguru?

Copy link
Copy Markdown
Contributor Author

@QuentiumYT QuentiumYT May 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well loguru is nowhere in scrap.py, I'm not sure how should I pass the logger to this method. Do I need to pass the logger instance through EcoindexScraper?

bases/ecoindex/cli/app.py and components/ecoindex/scraper/helper.py are the only files using the logger, I'm not sure how I you want it to look like ^^

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @vvatelot, any news on this? Let me know :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simply pass loguru to EcoindexScraper, like in the cli.
Keep it simple. I just prefer to use a logger than directly a print...

Copy link
Copy Markdown
Contributor Author

@QuentiumYT QuentiumYT May 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you are @vvatelot :) I was just asking how you want me to propose coherent changes

@vvatelot vvatelot changed the title Optional pillow requirement chore: Optional pillow requirement May 19, 2026
Copy link
Copy Markdown
Member

@vvatelot vvatelot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me !
Are you allowed to merge ?

@QuentiumYT
Copy link
Copy Markdown
Contributor Author

I am not allowed to merge but I allow you to merge :D

@vvatelot vvatelot merged commit 370c96e into cnumr:main May 22, 2026
1 of 3 checks passed
@QuentiumYT QuentiumYT deleted the optional-pillow branch May 22, 2026 10:57
@QuentiumYT
Copy link
Copy Markdown
Contributor Author

Could you create a new version for pypi so I can use it officially? Thanks @vvatelot

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 this pull request may close these issues.

2 participants