Skip to contentSkip to conversation

package/python-pillow: fix pkg-config search paths

PATCH Superseded James Hilliard 3 participants 8 messages Mar 16, 2022 – Mar 22, 2022

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/python-pillow: fix pkg-config search paths

Currently pillow doesn't correctly search pkg-config system paths for some libraries which can prevent some libraries from being properly detected/enabled in pillow.

---
 ...Search-pkg-config-system-libs-cflags.patch | 33 +++++++++++++++++++
 package/python-pillow/python-pillow.mk        | 23 +++----------
 2 files changed, 37 insertions(+), 19 deletions(-)
 create mode 100644 package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch
package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +33 -0
new file mode 100644
index 0000000000..9f979b048f
@@ -0,0 +1,33 @@
+From 89c9c347bb7437d5ea559930e315f42a0236761f Mon Sep 17 00:00:00 2001
+From: James Hilliard <[email protected]>
+Date: Tue, 15 Mar 2022 23:31:59 -0600
+Subject: [PATCH] Search pkg-config system libs/cflags.
+
+We need to search the system paths as well from pkg-config for
+some packages to be found properly.
+
+Signed-off-by: James Hilliard <[email protected]>
+[Upstream status:
+https://github.com/python-pillow/Pillow/pull/6138]
+---
+ setup.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/setup.py b/setup.py
+index 3468b260..59d65ce2 100755
+--- a/setup.py
++++ b/setup.py
+@@ -252,8 +252,8 @@ def _cmd_exists(cmd):
+ def _pkg_config(name):
+     try:
+         command = os.environ.get("PKG_CONFIG", "pkg-config")
+-        command_libs = [command, "--libs-only-L", name]
+-        command_cflags = [command, "--cflags-only-I", name]
++        command_libs = [command, "--libs-only-L", "--keep-system-libs", name]
++        command_cflags = [command, "--cflags-only-I", "--keep-system-cflags", name]
+         if not DEBUG:
+             command_libs.append("--silence-errors")
+             command_cflags.append("--silence-errors")
+-- 
+2.35.1
+
package/python-pillow/python-pillow.mk +4 -19
index 901876e0ee..ef677855b2 100644
@@ -12,7 +12,10 @@ PYTHON_PILLOW_LICENSE_FILES = LICENSE
 PYTHON_PILLOW_CPE_ID_VENDOR = python
 PYTHON_PILLOW_CPE_ID_PRODUCT = pillow
 PYTHON_PILLOW_SETUP_TYPE = setuptools
-PYTHON_PILLOW_BUILD_OPTS = --disable-platform-guessing
+PYTHON_PILLOW_ENV = MAX_CONCURRENCY="$(PARALLEL_JOBS)"
+
+PYTHON_PILLOW_DEPENDENCIES = host-pkgconf
+PYTHON_PILLOW_BUILD_OPTS = build_ext --disable-platform-guessing
 
 ifeq ($(BR2_PACKAGE_FREETYPE),y)
 PYTHON_PILLOW_DEPENDENCIES += freetype
@@ -68,22 +71,4 @@ else
 PYTHON_PILLOW_BUILD_OPTS += --disable-webp --disable-webpmux
 endif
 
-define PYTHON_PILLOW_BUILD_CMDS
-	cd $(PYTHON_PILLOW_BUILDDIR); \
-		PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
-		$(PYTHON_PILLOW_BASE_ENV) $(PYTHON_PILLOW_ENV) \
-		$(PYTHON_PILLOW_PYTHON_INTERPRETER) setup.py build_ext \
-		$(PYTHON_PILLOW_BASE_BUILD_OPTS) $(PYTHON_PILLOW_BUILD_OPTS)
-endef
-
-define PYTHON_PILLOW_INSTALL_TARGET_CMDS
-	cd $(PYTHON_PILLOW_BUILDDIR); \
-		PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
-		$(PYTHON_PILLOW_BASE_ENV) $(PYTHON_PILLOW_ENV) \
-		$(PYTHON_PILLOW_PYTHON_INTERPRETER) setup.py build_ext \
-		$(PYTHON_PILLOW_BUILD_OPTS) install \
-		$(PYTHON_PILLOW_BASE_INSTALL_TARGET_OPTS) \
-		$(PYTHON_PILLOW_INSTALL_TARGET_OPTS)
-endef
-
 $(eval $(python-package))
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Tested-by on v1 1/1
#1 lore raw
Quoted 6 lines · James Hilliard

Currently pillow doesn't correctly search pkg-config system paths for some libraries which can prevent some libraries from being properly detected/enabled in pillow.

Quoted 99 lines
---
 ...Search-pkg-config-system-libs-cflags.patch | 33 +++++++++++++++++++
 package/python-pillow/python-pillow.mk        | 23 +++----------
 2 files changed, 37 insertions(+), 19 deletions(-)
 create mode 100644

package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch

diff --git a/package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch b/package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file mode 100644
index 0000000000..9f979b048f

package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +26 -0
@@ -0,0 +1,33 @@
+From 89c9c347bb7437d5ea559930e315f42a0236761f Mon Sep 17 00:00:00 2001
+From: James Hilliard <[email protected]>
+Date: Tue, 15 Mar 2022 23:31:59 -0600
+Subject: [PATCH] Search pkg-config system libs/cflags.
+
+We need to search the system paths as well from pkg-config for
+some packages to be found properly.
+
+Signed-off-by: James Hilliard <[email protected]>
+[Upstream status:
+https://github.com/python-pillow/Pillow/pull/6138]
+---
+ setup.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/setup.py b/setup.py
+index 3468b260..59d65ce2 100755
+--- a/setup.py
++++ b/setup.py
+@@ -252,8 +252,8 @@ def _cmd_exists(cmd):
+ def _pkg_config(name):
+     try:
+         command = os.environ.get("PKG_CONFIG", "pkg-config")
+-        command_libs = [command, "--libs-only-L", name]
+-        command_cflags = [command, "--cflags-only-I", name]
++        command_libs = [command, "--libs-only-L", "--keep-system-libs",

name]
++ command_cflags = [command, "--cflags-only-I",
"--keep-system-cflags", name]

package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +6 -0
+         if not DEBUG:
+             command_libs.append("--silence-errors")
+             command_cflags.append("--silence-errors")
+--
+2.35.1
+
package/python-pillow/python-pillow.mk +4 -19
index 901876e0ee..ef677855b2 100644
@@ -12,7 +12,10 @@ PYTHON_PILLOW_LICENSE_FILES = LICENSE
 PYTHON_PILLOW_CPE_ID_VENDOR = python
 PYTHON_PILLOW_CPE_ID_PRODUCT = pillow
 PYTHON_PILLOW_SETUP_TYPE = setuptools
-PYTHON_PILLOW_BUILD_OPTS = --disable-platform-guessing
+PYTHON_PILLOW_ENV = MAX_CONCURRENCY="$(PARALLEL_JOBS)"
+
+PYTHON_PILLOW_DEPENDENCIES = host-pkgconf
+PYTHON_PILLOW_BUILD_OPTS = build_ext --disable-platform-guessing
 
 ifeq ($(BR2_PACKAGE_FREETYPE),y)
 PYTHON_PILLOW_DEPENDENCIES += freetype
@@ -68,22 +71,4 @@ else
 PYTHON_PILLOW_BUILD_OPTS += --disable-webp --disable-webpmux
 endif
 
-define PYTHON_PILLOW_BUILD_CMDS
-       cd $(PYTHON_PILLOW_BUILDDIR); \
-               PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
-               $(PYTHON_PILLOW_BASE_ENV) $(PYTHON_PILLOW_ENV) \
-               $(PYTHON_PILLOW_PYTHON_INTERPRETER) setup.py build_ext \
-               $(PYTHON_PILLOW_BASE_BUILD_OPTS)
 $(PYTHON_PILLOW_BUILD_OPTS)
-endef
-
-define PYTHON_PILLOW_INSTALL_TARGET_CMDS
-       cd $(PYTHON_PILLOW_BUILDDIR); \
-               PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
-               $(PYTHON_PILLOW_BASE_ENV) $(PYTHON_PILLOW_ENV) \
-               $(PYTHON_PILLOW_PYTHON_INTERPRETER) setup.py build_ext \
-               $(PYTHON_PILLOW_BUILD_OPTS) install \
-               $(PYTHON_PILLOW_BASE_INSTALL_TARGET_OPTS) \
-               $(PYTHON_PILLOW_INSTALL_TARGET_OPTS)
-endef
-

$(eval $(python-package))
--
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

Signature · 15 lines
Angelo Compagnucci

Software Engineer

[email protected]
__________________________________
Amarula Solutions SRL

Via le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 (0)42 243 5310
[email protected]

www.amarulasolutions.com
[`as] https://www.amarulasolutions.com|

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw
In reply to James Hilliard

Hi James,

Quoted 34 lines · James Hilliard

Currently pillow doesn't correctly search pkg-config system paths for some libraries which can prevent some libraries from being properly detected/enabled in pillow.

---
  ...Search-pkg-config-system-libs-cflags.patch | 33 +++++++++++++++++++
  package/python-pillow/python-pillow.mk        | 23 +++----------
  2 files changed, 37 insertions(+), 19 deletions(-)

create mode 100644 package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch

package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +17 -0
new file mode 100644
index 0000000000..9f979b048f
@@ -0,0 +1,33 @@
+From 89c9c347bb7437d5ea559930e315f42a0236761f Mon Sep 17 00:00:00 2001
+From: James Hilliard <[email protected]>
+Date: Tue, 15 Mar 2022 23:31:59 -0600
+Subject: [PATCH] Search pkg-config system libs/cflags.
+
+We need to search the system paths as well from pkg-config for
+some packages to be found properly.
+
+Signed-off-by: James Hilliard <[email protected]>
+[Upstream status:
+https://github.com/python-pillow/Pillow/pull/6138]
+---
+ setup.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/setup.py b/setup.py
+index 3468b260..59d65ce2 100755

package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch line 27

Quoted 10 lines
package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +10 -0
+--- a/setup.py
++++ b/setup.py
+@@ -252,8 +252,8 @@ def _cmd_exists(cmd):
+ def _pkg_config(name):
+     try:
+         command = os.environ.get("PKG_CONFIG", "pkg-config")
+-        command_libs = [command, "--libs-only-L", name]
+-        command_cflags = [command, "--cflags-only-I", name]
++        command_libs = [command, "--libs-only-L", "--keep-system-libs", name]
++        command_cflags = [command, "--cflags-only-I", "--keep-system-cflags", name]

You gave an additional explanation why this is needed in the upstream PR:

Zlib and anything that has headers in the normal system libs/include folders seems to not get their headers picked up without this change.

I think this issue is mostly going to be something people hit when cross compiling since the prefix based system libs/include folder would probably work in most of the usual cases(searching in sys.prefix will not work when cross compiling since it points to the host toolchain prefix rather than the target toolchain sysroot prefix):

However, that implies that either we have to make sure that sys.prefix is set
correctly (i.e. point it to staging instead of host), or pillow is using sys.prefix incorrectly.

Before that, still, I don't understand how this can be an issue. Unless if
pillow also passes something like -nostdinc, our toolchain wrapper should make sure that staging/usr/include is in the search path.

There also doesn't seem to be an autobuilder failure due to this... But maybe
it builds successfully, just without some optional dependency? Please provide more details about the failure in the commit message.

Quoted 11 lines
package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +6 -0
+         if not DEBUG:
+             command_libs.append("--silence-errors")
+             command_cflags.append("--silence-errors")
+--
+2.35.1
+
package/python-pillow/python-pillow.mk +0 -0
index 901876e0ee..ef677855b2 100644

package/python-pillow/python-pillow.mk PYTHON_PILLOW_LICENSE_FILES = LICENSE · line 15

Quoted 5 lines
package/python-pillow/python-pillow.mk +1 -1
@@ -12,7 +12,10 @@ PYTHON_PILLOW_LICENSE_FILES = LICENSE
  PYTHON_PILLOW_CPE_ID_VENDOR = python
  PYTHON_PILLOW_CPE_ID_PRODUCT = pillow
  PYTHON_PILLOW_SETUP_TYPE = setuptools
-PYTHON_PILLOW_BUILD_OPTS = --disable-platform-guessing
+PYTHON_PILLOW_ENV = MAX_CONCURRENCY="$(PARALLEL_JOBS)"

This change isn't explained in the commit message, and seems unrelated.

package/python-pillow/python-pillow.mk PYTHON_PILLOW_LICENSE_FILES = LICENSE · line 18

Quoted 3 lines
package/python-pillow/python-pillow.mk +3 -0
+
+PYTHON_PILLOW_DEPENDENCIES = host-pkgconf
+PYTHON_PILLOW_BUILD_OPTS = build_ext --disable-platform-guessing

The need for these two changes is also not clear at all from the commit message.

I've marked the patch as Changes Requested.

Regards,
Arnout

Quoted 16 lines
package/python-pillow/python-pillow.mk +0 -9
  ifeq ($(BR2_PACKAGE_FREETYPE),y)
  PYTHON_PILLOW_DEPENDENCIES += freetype
@@ -68,22 +71,4 @@ else
  PYTHON_PILLOW_BUILD_OPTS += --disable-webp --disable-webpmux
  endif
 
-define PYTHON_PILLOW_BUILD_CMDS
-	cd $(PYTHON_PILLOW_BUILDDIR); \
-		PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
-		$(PYTHON_PILLOW_BASE_ENV) $(PYTHON_PILLOW_ENV) \
-		$(PYTHON_PILLOW_PYTHON_INTERPRETER) setup.py build_ext \
-		$(PYTHON_PILLOW_BASE_BUILD_OPTS) $(PYTHON_PILLOW_BUILD_OPTS)
-endef
-
-define PYTHON_PILLOW_INSTALL_TARGET_CMDS

package/python-pillow/python-pillow.mk else · line 74

Quoted 10 lines
package/python-pillow/python-pillow.mk +0 -9
-	cd $(PYTHON_PILLOW_BUILDDIR); \
-		PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
-		$(PYTHON_PILLOW_BASE_ENV) $(PYTHON_PILLOW_ENV) \
-		$(PYTHON_PILLOW_PYTHON_INTERPRETER) setup.py build_ext \
-		$(PYTHON_PILLOW_BUILD_OPTS) install \
-		$(PYTHON_PILLOW_BASE_INSTALL_TARGET_OPTS) \
-		$(PYTHON_PILLOW_INSTALL_TARGET_OPTS)
-endef
-
  $(eval $(python-package))

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw
Quoted 61 lines · Arnout Vandecappelle

Hi James,

Quoted 34 lines · James Hilliard

Currently pillow doesn't correctly search pkg-config system paths for some libraries which can prevent some libraries from being properly detected/enabled in pillow.

---
  ...Search-pkg-config-system-libs-cflags.patch | 33 +++++++++++++++++++
  package/python-pillow/python-pillow.mk        | 23 +++----------
  2 files changed, 37 insertions(+), 19 deletions(-)

create mode 100644 package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch

package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +17 -0
new file mode 100644
index 0000000000..9f979b048f
@@ -0,0 +1,33 @@
+From 89c9c347bb7437d5ea559930e315f42a0236761f Mon Sep 17 00:00:00 2001
+From: James Hilliard <[email protected]>
+Date: Tue, 15 Mar 2022 23:31:59 -0600
+Subject: [PATCH] Search pkg-config system libs/cflags.
+
+We need to search the system paths as well from pkg-config for
+some packages to be found properly.
+
+Signed-off-by: James Hilliard <[email protected]>
+[Upstream status:
+https://github.com/python-pillow/Pillow/pull/6138]
+---
+ setup.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/setup.py b/setup.py
+index 3468b260..59d65ce2 100755

package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch line 27

Quoted 10 lines
package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +10 -0
+--- a/setup.py
++++ b/setup.py
+@@ -252,8 +252,8 @@ def _cmd_exists(cmd):
+ def _pkg_config(name):
+     try:
+         command = os.environ.get("PKG_CONFIG", "pkg-config")
+-        command_libs = [command, "--libs-only-L", name]
+-        command_cflags = [command, "--cflags-only-I", name]
++        command_libs = [command, "--libs-only-L", "--keep-system-libs", name]
++        command_cflags = [command, "--cflags-only-I", "--keep-system-cflags", name]

You gave an additional explanation why this is needed in the upstream PR:

Zlib and anything that has headers in the normal system libs/include folders seems to not get their headers picked up without this change.

I think this issue is mostly going to be something people hit when cross compiling since the prefix based system libs/include folder would probably work in most of the usual cases(searching in sys.prefix will not work when cross compiling since it points to the host toolchain prefix rather than the target toolchain sysroot prefix):

Quoted 3 lines

However, that implies that either we have to make sure that sys.prefix is set
correctly (i.e. point it to staging instead of host), or pillow is using sys.prefix incorrectly.

I think pillow is using sys.prefix in a way that is not really cross compilation compatible, however using pkg-config with sysm libs/cflags seems to be sufficient
for it to pass its non-standard header checks.

Quoted 4 lines

Before that, still, I don't understand how this can be an issue. Unless if
pillow also passes something like -nostdinc, our toolchain wrapper should make sure that staging/usr/include is in the search path.

It's due to pillow having custom header checks like this:
https://github.com/python-pillow/Pillow/blob/9.0.1/setup.py#L633

Quoted 4 lines

There also doesn't seem to be an autobuilder failure due to this... But maybe
it builds successfully, just without some optional dependency? Please provide more details about the failure in the commit message.

The failure was getting hidden by the non-standard build/install cmd overrides it
would appear, it seemed pillow was getting built for the host instead of the target with
those, I didn't investigate in too much detail as those custom build/install overrides
are not actually needed.

Quoted 52 lines
Quoted 14 lines
package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +6 -0
+         if not DEBUG:
+             command_libs.append("--silence-errors")
+             command_cflags.append("--silence-errors")
+--
+2.35.1
+
package/python-pillow/python-pillow.mk +0 -0
index 901876e0ee..ef677855b2 100644

package/python-pillow/python-pillow.mk PYTHON_PILLOW_LICENSE_FILES = LICENSE · line 15

Quoted 5 lines
package/python-pillow/python-pillow.mk +1 -1
@@ -12,7 +12,10 @@ PYTHON_PILLOW_LICENSE_FILES = LICENSE
  PYTHON_PILLOW_CPE_ID_VENDOR = python
  PYTHON_PILLOW_CPE_ID_PRODUCT = pillow
  PYTHON_PILLOW_SETUP_TYPE = setuptools
-PYTHON_PILLOW_BUILD_OPTS = --disable-platform-guessing
+PYTHON_PILLOW_ENV = MAX_CONCURRENCY="$(PARALLEL_JOBS)"

This change isn't explained in the commit message, and seems unrelated.

package/python-pillow/python-pillow.mk PYTHON_PILLOW_LICENSE_FILES = LICENSE · line 18

Quoted 3 lines
package/python-pillow/python-pillow.mk +3 -0
+
+PYTHON_PILLOW_DEPENDENCIES = host-pkgconf
+PYTHON_PILLOW_BUILD_OPTS = build_ext --disable-platform-guessing

The need for these two changes is also not clear at all from the commit message.

I've marked the patch as Changes Requested.

Regards,
Arnout

Quoted 18 lines
package/python-pillow/python-pillow.mk +0 -11
  ifeq ($(BR2_PACKAGE_FREETYPE),y)
  PYTHON_PILLOW_DEPENDENCIES += freetype
@@ -68,22 +71,4 @@ else
  PYTHON_PILLOW_BUILD_OPTS += --disable-webp --disable-webpmux
  endif
 
-define PYTHON_PILLOW_BUILD_CMDS
-     cd $(PYTHON_PILLOW_BUILDDIR); \
-             PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
-             $(PYTHON_PILLOW_BASE_ENV) $(PYTHON_PILLOW_ENV) \
-             $(PYTHON_PILLOW_PYTHON_INTERPRETER) setup.py build_ext \
-             $(PYTHON_PILLOW_BASE_BUILD_OPTS) $(PYTHON_PILLOW_BUILD_OPTS)
-endef
-
-define PYTHON_PILLOW_INSTALL_TARGET_CMDS
-     cd $(PYTHON_PILLOW_BUILDDIR); \
-             PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
Quoted 8 lines

package/python-pillow/python-pillow.mk else · line 74

Quoted 8 lines
package/python-pillow/python-pillow.mk +0 -7
-             $(PYTHON_PILLOW_BASE_ENV) $(PYTHON_PILLOW_ENV) \
-             $(PYTHON_PILLOW_PYTHON_INTERPRETER) setup.py build_ext \
-             $(PYTHON_PILLOW_BUILD_OPTS) install \
-             $(PYTHON_PILLOW_BASE_INSTALL_TARGET_OPTS) \
-             $(PYTHON_PILLOW_INSTALL_TARGET_OPTS)
-endef
-
  $(eval $(python-package))

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw
Quoted 77 lines · James Hilliard
Quoted 11 lines · Arnout Vandecappelle

Hi James,

Quoted 7 lines · James Hilliard

Currently pillow doesn't correctly search pkg-config system paths for some libraries which can prevent some libraries from being properly detected/enabled in pillow.

---
  ...Search-pkg-config-system-libs-cflags.patch | 33

+++++++++++++++++++

Quoted 3 lines
Quoted 3 lines
  package/python-pillow/python-pillow.mk        | 23 +++----------
  2 files changed, 37 insertions(+), 19 deletions(-)

create mode 100644

package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch

Quoted 2 lines
Quoted 2 lines

diff --git

a/package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch b/package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch

Quoted 4 lines
Quoted 4 lines

new file mode 100644
index 0000000000..9f979b048f
--- /dev/null
+++

b/package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch

Quoted 19 lines
Quoted 19 lines
package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +18 -0
@@ -0,0 +1,33 @@
+From 89c9c347bb7437d5ea559930e315f42a0236761f Mon Sep 17 00:00:00 2001
+From: James Hilliard <[email protected]>
+Date: Tue, 15 Mar 2022 23:31:59 -0600
+Subject: [PATCH] Search pkg-config system libs/cflags.
+
+We need to search the system paths as well from pkg-config for
+some packages to be found properly.
+
+Signed-off-by: James Hilliard <[email protected]>
+[Upstream status:
+https://github.com/python-pillow/Pillow/pull/6138]
+---
+ setup.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/setup.py b/setup.py
+index 3468b260..59d65ce2 100755
+--- a/setup.py
Quoted 8 lines

package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch

Quoted 8 lines
package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +8 -0
++++ b/setup.py
+@@ -252,8 +252,8 @@ def _cmd_exists(cmd):
+ def _pkg_config(name):
+     try:
+         command = os.environ.get("PKG_CONFIG", "pkg-config")
+-        command_libs = [command, "--libs-only-L", name]
+-        command_cflags = [command, "--cflags-only-I", name]
++        command_libs = [command, "--libs-only-L",

"--keep-system-libs", name]

Quoted 1 line

Review line 27

Quoted 1 line
(quoted diff) +1 -0
++        command_cflags = [command, "--cflags-only-I",

"--keep-system-cflags", name]

Quoted 2 lines

You gave an additional explanation why this is needed in the upstream

PR:

Quoted 2 lines

Zlib and anything that has headers in the normal system libs/include

folders

Quoted 4 lines

seems to not get their headers picked up without this change.

I think this issue is mostly going to be something people hit when cross compiling since the prefix based system libs/include folder would

probably work

Quoted 1 line

in most of the usual cases(searching in sys.prefix will not work when

cross

Quoted 1 line

compiling since it points to the host toolchain prefix rather than the

target

Quoted 4 lines

toolchain sysroot prefix):

However, that implies that either we have to make sure that sys.prefix

is set

Quoted 9 lines
Quoted 2 lines

correctly (i.e. point it to staging instead of host), or pillow is using sys.prefix incorrectly.

I think pillow is using sys.prefix in a way that is not really cross compilation
compatible, however using pkg-config with sysm libs/cflags seems to be sufficient
for it to pass its non-standard header checks.

I remember having added the --disable-platform-guessing exactly to overcome this problem. All the setting should be provided by buildroot. Probably, the logic behind this is slightly changed, and the mechanism doesn't work anymore. I'll try to have a look.

Quoted 94 lines
Quoted 3 lines

Before that, still, I don't understand how this can be an issue.

Unless if

Quoted 1 line

pillow also passes something like -nostdinc, our toolchain wrapper

should make

Quoted 1 line

sure that staging/usr/include is in the search path.

It's due to pillow having custom header checks like this:
https://github.com/python-pillow/Pillow/blob/9.0.1/setup.py#L633

Quoted 2 lines

There also doesn't seem to be an autobuilder failure due to this...

But maybe

Quoted 1 line

it builds successfully, just without some optional dependency? Please

provide

Quoted 1 line

more details about the failure in the commit message.

The failure was getting hidden by the non-standard build/install cmd overrides it
would appear, it seemed pillow was getting built for the host instead of the target with
those, I didn't investigate in too much detail as those custom build/install overrides
are not actually needed.

Quoted 10 lines

Review

Quoted 10 lines
package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +6 -0
+         if not DEBUG:
+             command_libs.append("--silence-errors")
+             command_cflags.append("--silence-errors")
+--
+2.35.1
+
(quoted diff) +0 -0

b/package/python-pillow/python-pillow.mk

Quoted 12 lines

package/python-pillow/python-pillow.mk PYTHON_PILLOW_LICENSE_FILES = LICENSE · line 15

Quoted 9 lines

index 901876e0ee..ef677855b2 100644

package/python-pillow/python-pillow.mk +1 -1
@@ -12,7 +12,10 @@ PYTHON_PILLOW_LICENSE_FILES = LICENSE
  PYTHON_PILLOW_CPE_ID_VENDOR = python
  PYTHON_PILLOW_CPE_ID_PRODUCT = pillow
  PYTHON_PILLOW_SETUP_TYPE = setuptools
-PYTHON_PILLOW_BUILD_OPTS = --disable-platform-guessing
+PYTHON_PILLOW_ENV = MAX_CONCURRENCY="$(PARALLEL_JOBS)"

This change isn't explained in the commit message, and seems unrelated.

Quoted 5 lines

package/python-pillow/python-pillow.mk PYTHON_PILLOW_LICENSE_FILES = LICENSE · line 18

Quoted 3 lines
package/python-pillow/python-pillow.mk +3 -0
+
+PYTHON_PILLOW_DEPENDENCIES = host-pkgconf
+PYTHON_PILLOW_BUILD_OPTS = build_ext --disable-platform-guessing

The need for these two changes is also not clear at all from the

commit message.

Quoted 14 lines

I've marked the patch as Changes Requested.

Regards,
Arnout

Quoted 7 lines
package/python-pillow/python-pillow.mk +0 -0
  ifeq ($(BR2_PACKAGE_FREETYPE),y)
  PYTHON_PILLOW_DEPENDENCIES += freetype
@@ -68,22 +71,4 @@ else
  PYTHON_PILLOW_BUILD_OPTS += --disable-webp --disable-webpmux
  endif
 
Quoted 6 lines

package/python-pillow/python-pillow.mk else

Quoted 6 lines
package/python-pillow/python-pillow.mk +0 -6
-define PYTHON_PILLOW_BUILD_CMDS
-     cd $(PYTHON_PILLOW_BUILDDIR); \
-             PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
-             $(PYTHON_PILLOW_BASE_ENV) $(PYTHON_PILLOW_ENV) \
-             $(PYTHON_PILLOW_PYTHON_INTERPRETER) setup.py build_ext \
-             $(PYTHON_PILLOW_BASE_BUILD_OPTS)

$(PYTHON_PILLOW_BUILD_OPTS)

Quoted 5 lines
Quoted 5 lines
package/python-pillow/python-pillow.mk +0 -5
-endef
-
-define PYTHON_PILLOW_INSTALL_TARGET_CMDS
-     cd $(PYTHON_PILLOW_BUILDDIR); \
-             PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
Quoted 8 lines

package/python-pillow/python-pillow.mk else · line 74

Quoted 8 lines
package/python-pillow/python-pillow.mk +0 -7
-             $(PYTHON_PILLOW_BASE_ENV) $(PYTHON_PILLOW_ENV) \
-             $(PYTHON_PILLOW_PYTHON_INTERPRETER) setup.py build_ext \
-             $(PYTHON_PILLOW_BUILD_OPTS) install \
-             $(PYTHON_PILLOW_BASE_INSTALL_TARGET_OPTS) \
-             $(PYTHON_PILLOW_INSTALL_TARGET_OPTS)
-endef
-
  $(eval $(python-package))

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

Signature · 15 lines
Angelo Compagnucci

Software Engineer

[email protected]
__________________________________
Amarula Solutions SRL

Via le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 (0)42 243 5310
[email protected]

www.amarulasolutions.com
[`as] https://www.amarulasolutions.com|

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#5 lore raw
Quoted 93 lines · Angelo Compagnucci
Quoted 78 lines · James Hilliard
Quoted 11 lines · Arnout Vandecappelle

Hi James,

Quoted 7 lines · James Hilliard

Currently pillow doesn't correctly search pkg-config system paths for some libraries which can prevent some libraries from being properly detected/enabled in pillow.

---
  ...Search-pkg-config-system-libs-cflags.patch | 33

+++++++++++++++++++

Quoted 3 lines
Quoted 3 lines
  package/python-pillow/python-pillow.mk        | 23 +++----------
  2 files changed, 37 insertions(+), 19 deletions(-)

create mode 100644

package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch

Quoted 2 lines
Quoted 2 lines

diff --git

a/package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch b/package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch

Quoted 4 lines
Quoted 4 lines

new file mode 100644
index 0000000000..9f979b048f
--- /dev/null
+++

b/package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch

Quoted 2 lines

Review line 1

Quoted 2 lines
(quoted diff) +1 -0
@@ -0,0 +1,33 @@
+From 89c9c347bb7437d5ea559930e315f42a0236761f Mon Sep 17 00:00:00

2001

Quoted 17 lines
Quoted 17 lines
package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +17 -0
+From: James Hilliard <[email protected]>
+Date: Tue, 15 Mar 2022 23:31:59 -0600
+Subject: [PATCH] Search pkg-config system libs/cflags.
+
+We need to search the system paths as well from pkg-config for
+some packages to be found properly.
+
+Signed-off-by: James Hilliard <[email protected]>
+[Upstream status:
+https://github.com/python-pillow/Pillow/pull/6138]
+---
+ setup.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/setup.py b/setup.py
+index 3468b260..59d65ce2 100755
+--- a/setup.py
Quoted 8 lines

package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch

Quoted 8 lines
package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +8 -0
++++ b/setup.py
+@@ -252,8 +252,8 @@ def _cmd_exists(cmd):
+ def _pkg_config(name):
+     try:
+         command = os.environ.get("PKG_CONFIG", "pkg-config")
+-        command_libs = [command, "--libs-only-L", name]
+-        command_cflags = [command, "--cflags-only-I", name]
++        command_libs = [command, "--libs-only-L",

"--keep-system-libs", name]

Quoted 1 line

Review line 27

Quoted 1 line
(quoted diff) +1 -0
++        command_cflags = [command, "--cflags-only-I",

"--keep-system-cflags", name]

Quoted 2 lines

You gave an additional explanation why this is needed in the upstream

PR:

Quoted 2 lines

Zlib and anything that has headers in the normal system libs/include

folders

Quoted 4 lines

seems to not get their headers picked up without this change.

I think this issue is mostly going to be something people hit when cross compiling since the prefix based system libs/include folder would

probably work

Quoted 1 line

in most of the usual cases(searching in sys.prefix will not work when

cross

Quoted 1 line

compiling since it points to the host toolchain prefix rather than the

target

Quoted 4 lines

toolchain sysroot prefix):

However, that implies that either we have to make sure that

sys.prefix is set

Quoted 9 lines
Quoted 2 lines

correctly (i.e. point it to staging instead of host), or pillow is using sys.prefix incorrectly.

I think pillow is using sys.prefix in a way that is not really cross compilation
compatible, however using pkg-config with sysm libs/cflags seems to be sufficient
for it to pass its non-standard header checks.

Quoted 5 lines

I remember having added the --disable-platform-guessing exactly to overcome this problem. All the setting should be provided by buildroot. Probably, the logic behind this is slightly changed, and the mechanism doesn't work anymore. I'll try to have a look.

Yes, basically the paths leaks some host directories:

[...]
Checking for include file %s in %s ('libimagequant.h', '/usr/local/include') Checking for include file %s in %s ('libimagequant.h', '/usr/include')

Looking forward for a fix.

Quoted 116 lines
Quoted 87 lines
Quoted 4 lines

Before that, still, I don't understand how this can be an issue.

Unless if

Quoted 1 line

pillow also passes something like -nostdinc, our toolchain wrapper

should make

Quoted 1 line

sure that staging/usr/include is in the search path.

It's due to pillow having custom header checks like this:
https://github.com/python-pillow/Pillow/blob/9.0.1/setup.py#L633

Quoted 2 lines

There also doesn't seem to be an autobuilder failure due to this...

But maybe

Quoted 1 line

it builds successfully, just without some optional dependency? Please

provide

Quoted 1 line

more details about the failure in the commit message.

The failure was getting hidden by the non-standard build/install cmd overrides it
would appear, it seemed pillow was getting built for the host instead of the target with
those, I didn't investigate in too much detail as those custom build/install overrides
are not actually needed.

Quoted 10 lines

Review

Quoted 10 lines
package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +6 -0
+         if not DEBUG:
+             command_libs.append("--silence-errors")
+             command_cflags.append("--silence-errors")
+--
+2.35.1
+
(quoted diff) +0 -0

b/package/python-pillow/python-pillow.mk

Quoted 11 lines

package/python-pillow/python-pillow.mk PYTHON_PILLOW_LICENSE_FILES = LICENSE · line 15

Quoted 9 lines

index 901876e0ee..ef677855b2 100644

package/python-pillow/python-pillow.mk +1 -1
@@ -12,7 +12,10 @@ PYTHON_PILLOW_LICENSE_FILES = LICENSE
  PYTHON_PILLOW_CPE_ID_VENDOR = python
  PYTHON_PILLOW_CPE_ID_PRODUCT = pillow
  PYTHON_PILLOW_SETUP_TYPE = setuptools
-PYTHON_PILLOW_BUILD_OPTS = --disable-platform-guessing
+PYTHON_PILLOW_ENV = MAX_CONCURRENCY="$(PARALLEL_JOBS)"

This change isn't explained in the commit message, and seems

unrelated.

Quoted 6 lines

package/python-pillow/python-pillow.mk PYTHON_PILLOW_LICENSE_FILES = LICENSE · line 18

Quoted 4 lines
package/python-pillow/python-pillow.mk +3 -0
+
+PYTHON_PILLOW_DEPENDENCIES = host-pkgconf
+PYTHON_PILLOW_BUILD_OPTS = build_ext --disable-platform-guessing

The need for these two changes is also not clear at all from the

commit message.

Quoted 14 lines

I've marked the patch as Changes Requested.

Regards,
Arnout

Quoted 7 lines
package/python-pillow/python-pillow.mk +0 -0
  ifeq ($(BR2_PACKAGE_FREETYPE),y)
  PYTHON_PILLOW_DEPENDENCIES += freetype
@@ -68,22 +71,4 @@ else
  PYTHON_PILLOW_BUILD_OPTS += --disable-webp --disable-webpmux
  endif
 
Quoted 6 lines

package/python-pillow/python-pillow.mk else

Quoted 6 lines
package/python-pillow/python-pillow.mk +0 -6
-define PYTHON_PILLOW_BUILD_CMDS
-     cd $(PYTHON_PILLOW_BUILDDIR); \
-             PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
-             $(PYTHON_PILLOW_BASE_ENV) $(PYTHON_PILLOW_ENV) \
-             $(PYTHON_PILLOW_PYTHON_INTERPRETER) setup.py build_ext \
-             $(PYTHON_PILLOW_BASE_BUILD_OPTS)

$(PYTHON_PILLOW_BUILD_OPTS)

Quoted 9 lines
Quoted 9 lines
package/python-pillow/python-pillow.mk +0 -9
-endef
-
-define PYTHON_PILLOW_INSTALL_TARGET_CMDS
-     cd $(PYTHON_PILLOW_BUILDDIR); \
-             PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
-             $(PYTHON_PILLOW_BASE_ENV) $(PYTHON_PILLOW_ENV) \
-             $(PYTHON_PILLOW_PYTHON_INTERPRETER) setup.py build_ext \
-             $(PYTHON_PILLOW_BUILD_OPTS) install \
-             $(PYTHON_PILLOW_BASE_INSTALL_TARGET_OPTS) \
Quoted 9 lines
Quoted 4 lines

package/python-pillow/python-pillow.mk else · line 74

Quoted 4 lines
package/python-pillow/python-pillow.mk +0 -3
-             $(PYTHON_PILLOW_INSTALL_TARGET_OPTS)
-endef
-
  $(eval $(python-package))

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

--

Angelo Compagnucci

Software Engineer

[email protected]
__________________________________
Amarula Solutions SRL

Via le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 (0)42 243 5310
[email protected]

www.amarulasolutions.com
[`as] https://www.amarulasolutions.com|

Signature · 15 lines
Angelo Compagnucci

Software Engineer

[email protected]
__________________________________
Amarula Solutions SRL

Via le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 (0)42 243 5310
[email protected]

www.amarulasolutions.com
[`as] https://www.amarulasolutions.com|

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#6 lore raw
Quoted 106 lines · Angelo Compagnucci
Quoted 95 lines · Angelo Compagnucci
Quoted 80 lines · James Hilliard
Quoted 11 lines · Arnout Vandecappelle

Hi James,

Quoted 7 lines · James Hilliard

Currently pillow doesn't correctly search pkg-config system paths for some libraries which can prevent some libraries from being properly detected/enabled in pillow.

---
  ...Search-pkg-config-system-libs-cflags.patch | 33

+++++++++++++++++++

Quoted 3 lines
Quoted 3 lines
  package/python-pillow/python-pillow.mk        | 23 +++----------
  2 files changed, 37 insertions(+), 19 deletions(-)

create mode 100644

package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch

Quoted 2 lines
Quoted 2 lines

diff --git

a/package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch b/package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch

Quoted 4 lines
Quoted 4 lines

new file mode 100644
index 0000000000..9f979b048f
--- /dev/null
+++

b/package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch

Quoted 2 lines

Review line 1

Quoted 2 lines
(quoted diff) +1 -0
@@ -0,0 +1,33 @@
+From 89c9c347bb7437d5ea559930e315f42a0236761f Mon Sep 17 00:00:00

2001

Quoted 17 lines
Quoted 17 lines
package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +17 -0
+From: James Hilliard <[email protected]>
+Date: Tue, 15 Mar 2022 23:31:59 -0600
+Subject: [PATCH] Search pkg-config system libs/cflags.
+
+We need to search the system paths as well from pkg-config for
+some packages to be found properly.
+
+Signed-off-by: James Hilliard <[email protected]>
+[Upstream status:
+https://github.com/python-pillow/Pillow/pull/6138]
+---
+ setup.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/setup.py b/setup.py
+index 3468b260..59d65ce2 100755
+--- a/setup.py
Quoted 8 lines

package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch

Quoted 8 lines
package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +8 -0
++++ b/setup.py
+@@ -252,8 +252,8 @@ def _cmd_exists(cmd):
+ def _pkg_config(name):
+     try:
+         command = os.environ.get("PKG_CONFIG", "pkg-config")
+-        command_libs = [command, "--libs-only-L", name]
+-        command_cflags = [command, "--cflags-only-I", name]
++        command_libs = [command, "--libs-only-L",

"--keep-system-libs", name]

Quoted 1 line

Review line 27

Quoted 1 line
(quoted diff) +1 -0
++        command_cflags = [command, "--cflags-only-I",

"--keep-system-cflags", name]

Quoted 2 lines

You gave an additional explanation why this is needed in the

upstream PR:

Quoted 2 lines

Zlib and anything that has headers in the normal system libs/include

folders

Quoted 3 lines

seems to not get their headers picked up without this change.

I think this issue is mostly going to be something people hit when

cross

Quoted 1 line

compiling since the prefix based system libs/include folder would

probably work

Quoted 1 line

in most of the usual cases(searching in sys.prefix will not work when

cross

Quoted 1 line

compiling since it points to the host toolchain prefix rather than the

target

Quoted 4 lines

toolchain sysroot prefix):

However, that implies that either we have to make sure that

sys.prefix is set

Quoted 1 line

correctly (i.e. point it to staging instead of host), or pillow is

Quoted 9 lines

using

Quoted 1 line

sys.prefix incorrectly.

I think pillow is using sys.prefix in a way that is not really cross compilation
compatible, however using pkg-config with sysm libs/cflags seems to be sufficient
for it to pass its non-standard header checks.

Quoted 5 lines

I remember having added the --disable-platform-guessing exactly to overcome this problem. All the setting should be provided by buildroot. Probably, the logic behind this is slightly changed, and the mechanism doesn't work anymore. I'll try to have a look.

Quoted 9 lines

Yes, basically the paths leaks some host directories:

[...]
Checking for include file %s in %s ('libimagequant.h', '/usr/local/include')
Checking for include file %s in %s ('libimagequant.h', '/usr/include')

Looking forward for a fix.

I came to the conclusion that James setup.py patch is necessary, pillow doesn't use sys.prefix but builds the paths from the pkg-config output. Withouth the patch, include and libraries directories are wrong. It misses a piece anyway

+PYTHON_PILLOW_BUILD_OPTS = build_ext --disable-platform-guessing +PYTHON_PILLOW_INSTALL_TARGET_OPTS = $(PYTHON_PILLOW_BUILD_OPTS) install

target install options should match the build ones to have a correct library installation.

Quoted 139 lines
Quoted 111 lines
Quoted 88 lines
Quoted 5 lines

Before that, still, I don't understand how this can be an issue.

Unless if

Quoted 1 line

pillow also passes something like -nostdinc, our toolchain wrapper

should make

Quoted 1 line

sure that staging/usr/include is in the search path.

It's due to pillow having custom header checks like this:
https://github.com/python-pillow/Pillow/blob/9.0.1/setup.py#L633

Quoted 2 lines

There also doesn't seem to be an autobuilder failure due to this...

But maybe

Quoted 1 line

it builds successfully, just without some optional dependency? Please

provide

Quoted 1 line

more details about the failure in the commit message.

The failure was getting hidden by the non-standard build/install cmd overrides it
would appear, it seemed pillow was getting built for the host instead of the target with
those, I didn't investigate in too much detail as those custom build/install overrides
are not actually needed.

Quoted 10 lines

Review

Quoted 10 lines
package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +6 -0
+         if not DEBUG:
+             command_libs.append("--silence-errors")
+             command_cflags.append("--silence-errors")
+--
+2.35.1
+
(quoted diff) +0 -0

b/package/python-pillow/python-pillow.mk

Quoted 11 lines

package/python-pillow/python-pillow.mk PYTHON_PILLOW_LICENSE_FILES = LICENSE · line 15

Quoted 9 lines

index 901876e0ee..ef677855b2 100644

package/python-pillow/python-pillow.mk +1 -1
@@ -12,7 +12,10 @@ PYTHON_PILLOW_LICENSE_FILES = LICENSE
  PYTHON_PILLOW_CPE_ID_VENDOR = python
  PYTHON_PILLOW_CPE_ID_PRODUCT = pillow
  PYTHON_PILLOW_SETUP_TYPE = setuptools
-PYTHON_PILLOW_BUILD_OPTS = --disable-platform-guessing
+PYTHON_PILLOW_ENV = MAX_CONCURRENCY="$(PARALLEL_JOBS)"

This change isn't explained in the commit message, and seems

unrelated.

Quoted 6 lines

package/python-pillow/python-pillow.mk PYTHON_PILLOW_LICENSE_FILES = LICENSE · line 18

Quoted 4 lines
package/python-pillow/python-pillow.mk +3 -0
+
+PYTHON_PILLOW_DEPENDENCIES = host-pkgconf
+PYTHON_PILLOW_BUILD_OPTS = build_ext --disable-platform-guessing

The need for these two changes is also not clear at all from the

commit message.

Quoted 14 lines

I've marked the patch as Changes Requested.

Regards,
Arnout

Quoted 7 lines
package/python-pillow/python-pillow.mk +0 -0
  ifeq ($(BR2_PACKAGE_FREETYPE),y)
  PYTHON_PILLOW_DEPENDENCIES += freetype
@@ -68,22 +71,4 @@ else
  PYTHON_PILLOW_BUILD_OPTS += --disable-webp --disable-webpmux
  endif
 
Quoted 5 lines

package/python-pillow/python-pillow.mk else

Quoted 5 lines
package/python-pillow/python-pillow.mk +0 -5
-define PYTHON_PILLOW_BUILD_CMDS
-     cd $(PYTHON_PILLOW_BUILDDIR); \
-             PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
-             $(PYTHON_PILLOW_BASE_ENV) $(PYTHON_PILLOW_ENV) \
-             $(PYTHON_PILLOW_PYTHON_INTERPRETER) setup.py build_ext

\

Quoted 1 line

package/python-pillow/python-pillow.mk else · line 76

Quoted 1 line
package/python-pillow/python-pillow.mk +0 -1
-             $(PYTHON_PILLOW_BASE_BUILD_OPTS)

$(PYTHON_PILLOW_BUILD_OPTS)

Quoted 7 lines

package/python-pillow/python-pillow.mk else

Quoted 7 lines
package/python-pillow/python-pillow.mk +0 -7
-endef
-
-define PYTHON_PILLOW_INSTALL_TARGET_CMDS
-     cd $(PYTHON_PILLOW_BUILDDIR); \
-             PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
-             $(PYTHON_PILLOW_BASE_ENV) $(PYTHON_PILLOW_ENV) \
-             $(PYTHON_PILLOW_PYTHON_INTERPRETER) setup.py build_ext

\

Quoted 11 lines
Quoted 6 lines

package/python-pillow/python-pillow.mk else · line 74

Quoted 6 lines
package/python-pillow/python-pillow.mk +0 -5
-             $(PYTHON_PILLOW_BUILD_OPTS) install \
-             $(PYTHON_PILLOW_BASE_INSTALL_TARGET_OPTS) \
-             $(PYTHON_PILLOW_INSTALL_TARGET_OPTS)
-endef
-
  $(eval $(python-package))

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

--

Angelo Compagnucci

Software Engineer

[email protected]
__________________________________
Amarula Solutions SRL

Quoted 8 lines

Via le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 (0)42 243 5310
[email protected]

www.amarulasolutions.com
[`as] https://www.amarulasolutions.com|

--

Angelo Compagnucci

Software Engineer

[email protected]
__________________________________
Amarula Solutions SRL

Via le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 (0)42 243 5310
[email protected]

www.amarulasolutions.com
[`as] https://www.amarulasolutions.com|

Signature · 15 lines
Angelo Compagnucci

Software Engineer

[email protected]
__________________________________
Amarula Solutions SRL

Via le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 (0)42 243 5310
[email protected]

www.amarulasolutions.com
[`as] https://www.amarulasolutions.com|

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#7 lore raw
Quoted 100 lines · Angelo Compagnucci
Quoted 84 lines · Angelo Compagnucci
Quoted 71 lines · Angelo Compagnucci
Quoted 67 lines · James Hilliard
Quoted 64 lines · Arnout Vandecappelle

Hi James,

Quoted 34 lines · James Hilliard

Currently pillow doesn't correctly search pkg-config system paths for some libraries which can prevent some libraries from being properly detected/enabled in pillow.

---
  ...Search-pkg-config-system-libs-cflags.patch | 33 +++++++++++++++++++
  package/python-pillow/python-pillow.mk        | 23 +++----------
  2 files changed, 37 insertions(+), 19 deletions(-)

create mode 100644 package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch

package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +17 -0
new file mode 100644
index 0000000000..9f979b048f
@@ -0,0 +1,33 @@
+From 89c9c347bb7437d5ea559930e315f42a0236761f Mon Sep 17 00:00:00 2001
+From: James Hilliard <[email protected]>
+Date: Tue, 15 Mar 2022 23:31:59 -0600
+Subject: [PATCH] Search pkg-config system libs/cflags.
+
+We need to search the system paths as well from pkg-config for
+some packages to be found properly.
+
+Signed-off-by: James Hilliard <[email protected]>
+[Upstream status:
+https://github.com/python-pillow/Pillow/pull/6138]
+---
+ setup.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/setup.py b/setup.py
+index 3468b260..59d65ce2 100755

package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch line 27

Quoted 10 lines
package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +10 -0
+--- a/setup.py
++++ b/setup.py
+@@ -252,8 +252,8 @@ def _cmd_exists(cmd):
+ def _pkg_config(name):
+     try:
+         command = os.environ.get("PKG_CONFIG", "pkg-config")
+-        command_libs = [command, "--libs-only-L", name]
+-        command_cflags = [command, "--cflags-only-I", name]
++        command_libs = [command, "--libs-only-L", "--keep-system-libs", name]
++        command_cflags = [command, "--cflags-only-I", "--keep-system-cflags", name]

You gave an additional explanation why this is needed in the upstream PR:

Zlib and anything that has headers in the normal system libs/include folders seems to not get their headers picked up without this change.

I think this issue is mostly going to be something people hit when cross compiling since the prefix based system libs/include folder would probably work in most of the usual cases(searching in sys.prefix will not work when cross compiling since it points to the host toolchain prefix rather than the target toolchain sysroot prefix):

However, that implies that either we have to make sure that sys.prefix is set
correctly (i.e. point it to staging instead of host), or pillow is using sys.prefix incorrectly.

Quoted 7 lines
Quoted 4 lines

I think pillow is using sys.prefix in a way that is not really cross compilation compatible, however using pkg-config with sysm libs/cflags seems to be sufficient
for it to pass its non-standard header checks.

I remember having added the --disable-platform-guessing exactly to overcome this problem. All the setting should be provided by buildroot. Probably, the logic behind this is slightly changed, and the mechanism doesn't work anymore. I'll try to have a look.

Quoted 7 lines

Yes, basically the paths leaks some host directories:

[...]
Checking for include file %s in %s ('libimagequant.h', '/usr/local/include') Checking for include file %s in %s ('libimagequant.h', '/usr/include')

Looking forward for a fix.

I came to the conclusion that James setup.py patch is necessary, pillow doesn't use sys.prefix but builds the paths from the pkg-config output. Withouth the patch, include and libraries directories are wrong. It misses a piece anyway

Review

Quoted 2 lines
(quoted diff) +2 -0
+PYTHON_PILLOW_BUILD_OPTS = build_ext --disable-platform-guessing
+PYTHON_PILLOW_INSTALL_TARGET_OPTS = $(PYTHON_PILLOW_BUILD_OPTS) install

https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

The install part isn't needed here since it will still get passed by _BASE_INSTALL_TARGET_CMD.

See:
https://github.com/buildroot/buildroot/blob/eaa8fcf546d84e38990566e49f4730c530d2577c/package/pkg-python.mk#L199
https://github.com/buildroot/buildroot/blob/eaa8fcf546d84e38990566e49f4730c530d2577c/package/pkg-python.mk#L285

Quoted 147 lines

target install options should match the build ones to have a correct library installation.

Quoted 123 lines
Quoted 102 lines
Quoted 81 lines
Quoted 8 lines

Before that, still, I don't understand how this can be an issue. Unless if
pillow also passes something like -nostdinc, our toolchain wrapper should make sure that staging/usr/include is in the search path.

It's due to pillow having custom header checks like this:
https://github.com/python-pillow/Pillow/blob/9.0.1/setup.py#L633

Quoted 4 lines

There also doesn't seem to be an autobuilder failure due to this... But maybe
it builds successfully, just without some optional dependency? Please provide more details about the failure in the commit message.

The failure was getting hidden by the non-standard build/install cmd overrides it
would appear, it seemed pillow was getting built for the host instead of the target with
those, I didn't investigate in too much detail as those custom build/install overrides
are not actually needed.

Quoted 56 lines
Quoted 14 lines
package/python-pillow/0001-Search-pkg-config-system-libs-cflags.patch new file +6 -0
+         if not DEBUG:
+             command_libs.append("--silence-errors")
+             command_cflags.append("--silence-errors")
+--
+2.35.1
+
package/python-pillow/python-pillow.mk +0 -0
index 901876e0ee..ef677855b2 100644

package/python-pillow/python-pillow.mk PYTHON_PILLOW_LICENSE_FILES = LICENSE · line 15

Quoted 5 lines
package/python-pillow/python-pillow.mk +1 -1
@@ -12,7 +12,10 @@ PYTHON_PILLOW_LICENSE_FILES = LICENSE
  PYTHON_PILLOW_CPE_ID_VENDOR = python
  PYTHON_PILLOW_CPE_ID_PRODUCT = pillow
  PYTHON_PILLOW_SETUP_TYPE = setuptools
-PYTHON_PILLOW_BUILD_OPTS = --disable-platform-guessing
+PYTHON_PILLOW_ENV = MAX_CONCURRENCY="$(PARALLEL_JOBS)"

This change isn't explained in the commit message, and seems unrelated.

package/python-pillow/python-pillow.mk PYTHON_PILLOW_LICENSE_FILES = LICENSE · line 18

Quoted 3 lines
package/python-pillow/python-pillow.mk +3 -0
+
+PYTHON_PILLOW_DEPENDENCIES = host-pkgconf
+PYTHON_PILLOW_BUILD_OPTS = build_ext --disable-platform-guessing

The need for these two changes is also not clear at all from the commit message.

I've marked the patch as Changes Requested.

Regards,
Arnout

Quoted 22 lines
package/python-pillow/python-pillow.mk +0 -15
  ifeq ($(BR2_PACKAGE_FREETYPE),y)
  PYTHON_PILLOW_DEPENDENCIES += freetype
@@ -68,22 +71,4 @@ else
  PYTHON_PILLOW_BUILD_OPTS += --disable-webp --disable-webpmux
  endif
 
-define PYTHON_PILLOW_BUILD_CMDS
-     cd $(PYTHON_PILLOW_BUILDDIR); \
-             PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
-             $(PYTHON_PILLOW_BASE_ENV) $(PYTHON_PILLOW_ENV) \
-             $(PYTHON_PILLOW_PYTHON_INTERPRETER) setup.py build_ext \
-             $(PYTHON_PILLOW_BASE_BUILD_OPTS) $(PYTHON_PILLOW_BUILD_OPTS)
-endef
-
-define PYTHON_PILLOW_INSTALL_TARGET_CMDS
-     cd $(PYTHON_PILLOW_BUILDDIR); \
-             PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
-             $(PYTHON_PILLOW_BASE_ENV) $(PYTHON_PILLOW_ENV) \
-             $(PYTHON_PILLOW_PYTHON_INTERPRETER) setup.py build_ext \
-             $(PYTHON_PILLOW_BUILD_OPTS) install \
-             $(PYTHON_PILLOW_BASE_INSTALL_TARGET_OPTS) \
Quoted 8 lines
Quoted 4 lines

package/python-pillow/python-pillow.mk else · line 74

Quoted 4 lines
package/python-pillow/python-pillow.mk +0 -3
-             $(PYTHON_PILLOW_INSTALL_TARGET_OPTS)
-endef
-
  $(eval $(python-package))

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

--

Angelo Compagnucci

Software Engineer

[email protected]
__________________________________
Amarula Solutions SRL

Quoted 8 lines

Via le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 (0)42 243 5310
[email protected]

www.amarulasolutions.com

[`as] https://www.amarulasolutions.com|

--

Angelo Compagnucci

Software Engineer

[email protected]
__________________________________
Amarula Solutions SRL

Quoted 8 lines

Via le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 (0)42 243 5310
[email protected]

www.amarulasolutions.com

[`as] https://www.amarulasolutions.com|

--

Angelo Compagnucci

Software Engineer

[email protected]
__________________________________
Amarula Solutions SRL

Quoted 8 lines

Via le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 (0)42 243 5310
[email protected]

www.amarulasolutions.com

[`as] https://www.amarulasolutions.com|

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot