Skip to contentSkip to conversation

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

PATCH Applied James Hilliard 3 participants 3 messages May 2, 2022 – May 28, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v5 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.

This is due to pillow implementing custom header validation checks which need system paths present to function correctly:
https://github.com/python-pillow/Pillow/blob/9.0.1/setup.py#L633

Removed custom BUILD_CMDS and INSTALL_TARGET_CMDS which were causing python-pillow to be installed for the host, they are not required, we just need to set build_ext at the start of PYTHON_PILLOW_BUILD_OPTS instead.

---
Changes v4 -> v5:
- use backported upstream patch
Changes v3 -> v4:
- pass BUILD_OPTS to INSTALL_TARGET_OPTS
Changes v2 -> v3:
- actually remove MAX_CONCURRENCY env variable
Changes v1 -> v2:
- remove unrelated MAX_CONCURRENCY env variable

---
 ...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..d0552ce0f4
@@ -0,0 +1,33 @@
+From 9ea46247048f861f088f09541cd434aeb16e6f9c 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]>
+[[email protected]: backport from upstream commit
+9ea46247048f861f088f09541cd434aeb16e6f9c]
+---
+ setup.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/setup.py b/setup.py
+index 9a05e5105..d41aedbd6 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.25.1
+
package/python-pillow/python-pillow.mk +4 -19
index 901876e0ee..1d99f44fa1 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_DEPENDENCIES = host-pkgconf
+PYTHON_PILLOW_BUILD_OPTS = build_ext --disable-platform-guessing
+PYTHON_PILLOW_INSTALL_TARGET_OPTS = $(PYTHON_PILLOW_BUILD_OPTS)
 
 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
#1 lore raw
Quoted 8 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.

This is due to pillow implementing custom header validation checks which need system paths present to function correctly:
https://github.com/python-pillow/Pillow/blob/9.0.1/setup.py#L633

Quoted 6 lines

Removed custom BUILD_CMDS and INSTALL_TARGET_CMDS which were causing python-pillow to be installed for the host, they are not required, we just need to set build_ext at the start of PYTHON_PILLOW_BUILD_OPTS instead.

Applied to master, thanks.

Regards,
Arnout

Quoted 83 lines

---
Changes v4 -> v5:
- use backported upstream patch
Changes v3 -> v4:
- pass BUILD_OPTS to INSTALL_TARGET_OPTS
Changes v2 -> v3:
- actually remove MAX_CONCURRENCY env variable
Changes v1 -> v2:
- remove unrelated MAX_CONCURRENCY env variable

---
  ...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..d0552ce0f4
@@ -0,0 +1,33 @@
+From 9ea46247048f861f088f09541cd434aeb16e6f9c 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]>
+[[email protected]: backport from upstream commit
+9ea46247048f861f088f09541cd434aeb16e6f9c]
+---
+ setup.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/setup.py b/setup.py
+index 9a05e5105..d41aedbd6 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.25.1
+
package/python-pillow/python-pillow.mk +4 -10
index 901876e0ee..1d99f44fa1 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_DEPENDENCIES = host-pkgconf
+PYTHON_PILLOW_BUILD_OPTS = build_ext --disable-platform-guessing
+PYTHON_PILLOW_INSTALL_TARGET_OPTS = $(PYTHON_PILLOW_BUILD_OPTS)
 
  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

#2 lore raw
In reply to James Hilliard
Quoted 16 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"James" == James Hilliard <[email protected]> writes:

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.

This is due to pillow implementing custom header validation checks which need system paths present to function correctly:
https://github.com/python-pillow/Pillow/blob/9.0.1/setup.py#L633

Removed custom BUILD_CMDS and INSTALL_TARGET_CMDS which were causing python-pillow to be installed for the host, they are not required, we just need to set build_ext at the start of PYTHON_PILLOW_BUILD_OPTS instead.

Quoted 9 lines

---
Changes v4 -> v5:
- use backported upstream patch
Changes v3 -> v4:
- pass BUILD_OPTS to INSTALL_TARGET_OPTS
Changes v2 -> v3:
- actually remove MAX_CONCURRENCY env variable
Changes v1 -> v2:
- remove unrelated MAX_CONCURRENCY env variable

Committed to 2022.02.x, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot