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
pillow: update to version 6.0.0, add Python3 variant #8715
Conversation
Added zlib support and currently supported: Python 2.7
Python 3.7
According to their doc: https://pillow.readthedocs.io/en/stable/installation.html
cc: @cotequeiroz (it is dependency for python-qrcode) and Python maintainers: @jefferyto , @commodo (who would like to take maintainership of this package) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, independently of my suggestion to add the maintainer.
63adb6a
to
602a7e6
Compare
define_macros=defs)) | ||
|
||
- tk_libs = ['psapi'] if sys.platform == 'win32' else [] | ||
+ tk_libs = ['psapi'] if host_platform == 'win32' else [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does this need to change ?
or is it needed ?
not sure if it will be true, ever ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure why the original Debian patch replaces sys.platform
with host_platform
(set from sysconfig.get_platform()
), but if I had to guess I would say for cross-compilation reasons.
I think we should probably continue replacing sys.platform
with host_platform
as well, but instead set host_platform = "linux"
. In theory, this could be compiling on macOS where sys.platform
(for host Python) would be `"darwin" (with similar changes on other host OSes).
- if (sys.platform in ["win32", "darwin"] and | ||
- _find_library_file(self, "libtiff")): | ||
- feature.tiff = "libtiff" | ||
+ feature.tiff= "tiff" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you just add feature.tiff= "tiff"
here and leave the removed lines, it has the same effect
makes patch smaller
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ feature.tiff= "tiff" | |
+ feature.tiff= "tiff" # openwrt: always use tiff |
If we are to do this, I would suggest to add a comment--inline to keep your intention to keep the patch small--to indicate we're trumping the above code. It should make it easier to understand what's going on.
- elif (sys.platform == "win32" and | ||
- _find_library_file(self, "libjpeg")): | ||
- feature.jpeg = "libjpeg" # alternative name | ||
+ feature.jpeg = "jpeg" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment here for leaving removed lines here
- elif (sys.platform == "win32" and | ||
- _find_library_file(self, "zlib")): | ||
- feature.zlib = "zlib" # alternative name | ||
+ feature.zlib = "z" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment here for leaving removed lines here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if hard-coding feature.zlib = "z"
(and the other lines for the other libraries) is really necessary. If the paths are correct, setup should be able to find the correct libraries. (I would again replace sys.platform
s with host_platform
as in the Debian patch.)
If it isn't able to find the libraries, we should find out why and fix that.
- | ||
- # on Windows, look for the OpenJPEG libraries in the location that | ||
- # the official installer puts them | ||
- if sys.platform == "win32": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just leave these lines here for win32;
makes patch smaller
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually can leave all the different branches in place (and replace sys.platform
s with host_platform
as in the Debian patch), since none of them should match.
# | ||
- # add platform directories | ||
- | ||
- if self.disable_platform_guessing: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for this if block removal; same idea: instead of removing it, just add
self.disable_platform_guessing = True
and all is well, patch is smaller;
it could be that self.disable_platform_guessing
can be disabled via some CLI arg;
i would need to check
_add_directory(library_dirs, d) | ||
|
||
- prefix = sysconfig.get_config_var("prefix") | ||
+ prefix = os.environ.get('PYTHONXCPREFIX') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curios: is this necessary ?
typically the prefix can be obtained from the CONFIGURE_ARGS reasonably ok
if this isn't true, we can try to fix it
i wouldn't mind having this here either; but if we could not patch this, it would be better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it already reads from several environment variables, which should have all the paths it needs?
Also... I don't see where PYTHONXCPREFIX
is defined.
I would be interested to see what sysconfig.get_config_var("prefix")
returns.
@BKPepe You may want to add a |
-TIFF_ROOT = None | ||
-FREETYPE_ROOT = None | ||
+TIFF_ROOT = os.path.join(os.environ['STAGING_DIR'], "/usr/lib") | ||
+FREETYPE_ROOT = os.path.join(os.environ['STAGING_DIR'], "/usr/lib") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like build_extensions()
already checks for environment variables, so you can set JPEG_ROOT
, ZLIB_ROOT
, etc. as variables from the Makefile instead of patching here.
But more importantly, it's suppose to use pkg-config to find these paths. I'd be interested to see why it doesn't work and perhaps fix that, instead of manually setting the paths.
+ _add_directory(self.compiler.include_dirs, | ||
+ line.strip()) | ||
+ finally: | ||
+ os.unlink(tmpfile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this comes from the Debian patch, but AFAICT this function (add_gcc_paths()
) isn't called anywhere. Can you try removing this?
_add_directory(library_dirs, d) | ||
|
||
- prefix = sysconfig.get_config_var("prefix") | ||
+ prefix = os.environ.get('PYTHONXCPREFIX') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it already reads from several environment variables, which should have all the paths it needs?
Also... I don't see where PYTHONXCPREFIX
is defined.
I would be interested to see what sysconfig.get_config_var("prefix")
returns.
- | ||
- # on Windows, look for the OpenJPEG libraries in the location that | ||
- # the official installer puts them | ||
- if sys.platform == "win32": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually can leave all the different branches in place (and replace sys.platform
s with host_platform
as in the Debian patch), since none of them should match.
- elif (sys.platform == "win32" and | ||
- _find_library_file(self, "zlib")): | ||
- feature.zlib = "zlib" # alternative name | ||
+ feature.zlib = "z" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if hard-coding feature.zlib = "z"
(and the other lines for the other libraries) is really necessary. If the paths are correct, setup should be able to find the correct libraries. (I would again replace sys.platform
s with host_platform
as in the Debian patch.)
If it isn't able to find the libraries, we should find out why and fix that.
define_macros=defs)) | ||
|
||
- tk_libs = ['psapi'] if sys.platform == 'win32' else [] | ||
+ tk_libs = ['psapi'] if host_platform == 'win32' else [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure why the original Debian patch replaces sys.platform
with host_platform
(set from sysconfig.get_platform()
), but if I had to guess I would say for cross-compilation reasons.
I think we should probably continue replacing sys.platform
with host_platform
as well, but instead set host_platform = "linux"
. In theory, this could be compiling on macOS where sys.platform
(for host Python) would be `"darwin" (with similar changes on other host OSes).
lang/python/pillow/Makefile
Outdated
CATEGORY:=Languages | ||
TITLE:=The friendly PIL fork | ||
URL:=https://python-pillow.org/ | ||
DEPENDS:=+libjpeg +libtiff +zlib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
libfreetype was also a dependency before... Are we sure it isn't still necessary (especially since this is a dependency of django-simple-captcha and captchas involve text...)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't compile with libfreetype, that's why I removed it.
Hmm... starting a review meant my comments are displayed separately from @commodo's. Wish I knew that beforehand. |
Guys, you really give me a hard time. :-) Anyway, hard-coding feature.zlib = "z" works and without it doesn't work. I was fighting with it for a while, but if you enable debug it will show you more outputs. Not sure, if I would be able to look at all the feedback today. |
@BKPepe 😂 if I have time later I might try compiling this as well |
It's not funny. :( I was so happy that I was able to compile Pillow for Python3 and this is not what I expected. :D |
If it's any consolation, I'm laughing with you not at you 😆 |
I've tried compiling this, and I was able to do so with these changes:
|
3f17009
to
a1c5a3f
Compare
- Add @commodo as maintainer Co-Authored-By: Jeffery To <jeffery.to@gmail.com> Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
Many thanks to @jefferyto for his work. I updated pillow to version 6.1.0, which includes his fix. Removed entirely Debian patch as it was replacing
|
Tested on master, both variants of Pillow with example Create thumbnails. |
Thank you :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glad it worked out 😂
Maintainer: none
Compile tested: Turris MOX, cortexa53, OpenWrt master
Run tested: Turris MOX, cortexa53, OpenWrt master
together with Create thumbnails from their documentation
Description: