[image] Remove dependency on libmagic
What does this implement/fix?
Use of libmagic is problematic on windows and requires native libraries installed on other host systems, and running the codeowners script requires it to be installed due to it being used by image. It's only used to detect an SVG file and in any case does so solely by searching for a string. This PR replicates that behaviour without bringing in a heavyweight external library.
Also change display from a dependency to an auto-load since image does not depend on having a display configured, only the header file available.
Types of changes
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [x] Other
Related issue or feature (if applicable): fixes
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#<esphome-docs PR number goes here>
Test Environment
- [x] ESP32
- [ ] ESP32 IDF
- [ ] ESP8266
- [ ] RP2040
- [ ] BK72xx
- [ ] RTL87xx
- [ ] host
Example entry for config.yaml:
# Example config.yaml
Checklist:
- [x] The code change is tested and works locally.
- [x] Tests have been added to verify that the new code works (under
tests/folder).
If user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated in esphome-docs.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 53.96%. Comparing base (
4d8b5ed) to head (7042e3a). Report is 1311 commits behind head on dev.
Additional details and impacted files
@@ Coverage Diff @@
## dev #7365 +/- ##
==========================================
+ Coverage 53.70% 53.96% +0.25%
==========================================
Files 50 50
Lines 9408 9670 +262
Branches 1654 1707 +53
==========================================
+ Hits 5053 5218 +165
- Misses 4056 4128 +72
- Partials 299 324 +25
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Did you intended to push 2 changes in this PR :D
Did you intended to push 2 changes in this PR
Yes, without those it fails CI.
@clydebarrow can you add issue 5896 to the "fixes" line in the description? As far as I can see, that issue is exactly what you are trying to fix here
IMHO the invert_colors changes on the tests belong in a separate PR... They are unrelated to this change, but to the one that made it mandatory
IMHO the
invert_colorschanges on the tests belong in a separate PR
True, but without those (actually now only one) this PR won't pass CI. I'm not going to raise a separate PR to change a single line, sorry Jesse, but I'm drawing a line here :-)
True, but without those (actually now only one) this PR won't pass CI. I'm not going to raise a separate PR to change a single line, sorry Jesse, but I'm drawing a line here :-)
Your PR is adding invert_colors to the spi config :thinking:
It already exists on the display for this test...
And its not failing becuase the 8266 commmon file is not used anywhere :see_no_evil:
Another alternative is https://pypi.org/project/puremagic/ Especially if other file types are added and need to be identified before some code runs in the future.
Another alternative is https://pypi.org/project/puremagic/ Especially if other file types are added and need to be identified before some code runs in the future.
I like this option! I want to determine the type of an audio file (wav, flac, or mp3), and I'm currently using libmagic for it. Puremagic is pretty much a straight drop in replacement.
Since there seems to be no movement here, I've implemented the "puremagic" version in #7536. So probably only one of the two PRs should be merged, since they address the same issue in two different ways