mirror of
https://gitee.com/open-loongarch/buildroot-2024.08.git
synced 2026-10-28 22:17:12 +08:00
first commit: base 2024.08
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn>
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
From ca3417b8d605ccdb2e6c516c5e0c79180381627c Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= <raphael.melotte@mind.be>
|
||||
Date: Sun, 4 Feb 2024 16:13:45 +0100
|
||||
Subject: [PATCH] pipcl.py: allow providing python-config externally
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
When cross-compiling (e.g. using Buildroot), the python-config
|
||||
executable that resides next to the host python executable provides
|
||||
incorrect includes (the ones for the host).
|
||||
|
||||
Since the correct path to python-config cannot be guessed, add an
|
||||
additional environment variable to allow setting the path to the
|
||||
correct python-config executable externally.
|
||||
|
||||
Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
|
||||
Upstream: https://github.com/pymupdf/PyMuPDF/commit/3a214b0c144d86fd1329b26030f6b9f2a6b27020
|
||||
---
|
||||
pipcl.py | 72 +++++++++++++++++++++++++++++---------------------------
|
||||
setup.py | 3 +++
|
||||
2 files changed, 40 insertions(+), 35 deletions(-)
|
||||
|
||||
diff --git a/pipcl.py b/pipcl.py
|
||||
index 209f660..c154774 100644
|
||||
--- a/pipcl.py
|
||||
+++ b/pipcl.py
|
||||
@@ -1789,43 +1789,45 @@ class PythonFlags:
|
||||
self.ldflags = f'-L {_lib_dir}'
|
||||
|
||||
else:
|
||||
- # We use python-config which appears to work better than pkg-config
|
||||
- # because it copes with multiple installed python's, e.g.
|
||||
- # manylinux_2014's /opt/python/cp*-cp*/bin/python*.
|
||||
- #
|
||||
- # But... on non-macos it seems that we should not attempt to specify
|
||||
- # libpython on the link command. The manylinux docker containers
|
||||
- # don't actually contain libpython.so, and it seems that this
|
||||
- # deliberate. And the link command runs ok.
|
||||
- #
|
||||
- python_exe = os.path.realpath( sys.executable)
|
||||
- if darwin():
|
||||
- # Basic install of dev tools with `xcode-select --install` doesn't
|
||||
- # seem to provide a `python3-config` or similar, but there is a
|
||||
- # `python-config.py` accessible via sysconfig.
|
||||
+ python_config = os.environ.get("PYMUPDF_PYTHON_CONFIG")
|
||||
+ if not python_config:
|
||||
+ # We use python-config which appears to work better than pkg-config
|
||||
+ # because it copes with multiple installed python's, e.g.
|
||||
+ # manylinux_2014's /opt/python/cp*-cp*/bin/python*.
|
||||
#
|
||||
- # We try different possibilities and use the last one that
|
||||
- # works.
|
||||
+ # But... on non-macos it seems that we should not attempt to specify
|
||||
+ # libpython on the link command. The manylinux docker containers
|
||||
+ # don't actually contain libpython.so, and it seems that this
|
||||
+ # deliberate. And the link command runs ok.
|
||||
#
|
||||
- python_config = None
|
||||
- for pc in (
|
||||
- f'python3-config',
|
||||
- f'{sys.executable} {sysconfig.get_config_var("srcdir")}/python-config.py',
|
||||
- f'{python_exe}-config',
|
||||
- ):
|
||||
- e = subprocess.run(
|
||||
- f'{pc} --includes',
|
||||
- shell=1,
|
||||
- stdout=subprocess.DEVNULL,
|
||||
- stderr=subprocess.DEVNULL,
|
||||
- check=0,
|
||||
- ).returncode
|
||||
- log1(f'{e=} from {pc!r}.')
|
||||
- if e == 0:
|
||||
- python_config = pc
|
||||
- assert python_config, f'Cannot find python-config'
|
||||
- else:
|
||||
- python_config = f'{python_exe}-config'
|
||||
+ python_exe = os.path.realpath( sys.executable)
|
||||
+ if darwin():
|
||||
+ # Basic install of dev tools with `xcode-select --install` doesn't
|
||||
+ # seem to provide a `python3-config` or similar, but there is a
|
||||
+ # `python-config.py` accessible via sysconfig.
|
||||
+ #
|
||||
+ # We try different possibilities and use the last one that
|
||||
+ # works.
|
||||
+ #
|
||||
+ python_config = None
|
||||
+ for pc in (
|
||||
+ f'python3-config',
|
||||
+ f'{sys.executable} {sysconfig.get_config_var("srcdir")}/python-config.py',
|
||||
+ f'{python_exe}-config',
|
||||
+ ):
|
||||
+ e = subprocess.run(
|
||||
+ f'{pc} --includes',
|
||||
+ shell=1,
|
||||
+ stdout=subprocess.DEVNULL,
|
||||
+ stderr=subprocess.DEVNULL,
|
||||
+ check=0,
|
||||
+ ).returncode
|
||||
+ log1(f'{e=} from {pc!r}.')
|
||||
+ if e == 0:
|
||||
+ python_config = pc
|
||||
+ assert python_config, f'Cannot find python-config'
|
||||
+ else:
|
||||
+ python_config = f'{python_exe}-config'
|
||||
log1(f'Using {python_config=}.')
|
||||
try:
|
||||
self.includes = run( f'{python_config} --includes', capture=1).strip()
|
||||
diff --git a/setup.py b/setup.py
|
||||
index 23a5c78..4b3b5c7 100755
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -36,6 +36,9 @@ Environmental variables:
|
||||
PYMUPDF_MUPDF_LIB
|
||||
Directory containing MuPDF libraries, (libmupdf.so,
|
||||
libmupdfcpp.so).
|
||||
+
|
||||
+ PYMUPDF_PYTHON_CONFIG
|
||||
+ Optional path to python-config.
|
||||
|
||||
PYMUPDF_SETUP_IMPLEMENTATIONS
|
||||
Must be one of 'a', 'b', 'ab'. If unset we use 'ab'.
|
||||
--
|
||||
2.41.0
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
config BR2_PACKAGE_PYTHON_PYMUPDF
|
||||
bool "python-pymupdf"
|
||||
depends on BR2_INSTALL_LIBSTDCPP # mupdf -> harfbuzz
|
||||
depends on BR2_TOOLCHAIN_HAS_SYNC_4 # mupdf -> harfbuzz
|
||||
depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # mupdf -> harfbuzz
|
||||
depends on !BR2_STATIC_LIBS # runtime failure
|
||||
select BR2_PACKAGE_HOST_SWIG
|
||||
select BR2_PACKAGE_FREETYPE
|
||||
select BR2_PACKAGE_MUPDF
|
||||
select BR2_PACKAGE_PYTHON3_ZLIB # runtime
|
||||
help
|
||||
Python bindings for the PDF rendering library MuPDF.
|
||||
|
||||
https://github.com/pymupdf/PyMuPDF
|
||||
|
||||
comment "python-pymupdf needs a toolchain w/ C++, gcc >= 4.9, dynamic library"
|
||||
depends on BR2_TOOLCHAIN_HAS_SYNC_4
|
||||
depends on !BR2_INSTALL_LIBSTDCPP || \
|
||||
!BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 || \
|
||||
BR2_STATIC_LIBS
|
||||
@@ -0,0 +1,5 @@
|
||||
# md5, sha256 from https://pypi.org/pypi/pymupdf/json
|
||||
md5 5c219a0c4cb3d57b60e39cc901ebd220 PyMuPDF-1.23.22.tar.gz
|
||||
sha256 c41cd91d83696cea67a4b6c65cc1951c2019ac0a561c5a3f543318ede30d3cd0 PyMuPDF-1.23.22.tar.gz
|
||||
# Locally computed sha256 checksums
|
||||
sha256 57c8ff33c9c0cfc3ef00e650a1cc910d7ee479a8bc509f6c9209a7c2a11399d6 COPYING
|
||||
@@ -0,0 +1,25 @@
|
||||
################################################################################
|
||||
#
|
||||
# python-pymupdf
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# python-pymupdf's version must be compatible with mupdf's version
|
||||
PYTHON_PYMUPDF_VERSION = 1.23.22
|
||||
PYTHON_PYMUPDF_SOURCE = PyMuPDF-$(PYTHON_PYMUPDF_VERSION).tar.gz
|
||||
PYTHON_PYMUPDF_SITE = https://files.pythonhosted.org/packages/05/20/a0d1221d8f379afcc12b4d1687a8f4adb69eef659e835d781c3fa331ff46
|
||||
PYTHON_PYMUPDF_SETUP_TYPE = setuptools
|
||||
PYTHON_PYMUPDF_LICENSE = AGPL-3.0+
|
||||
PYTHON_PYMUPDF_LICENSE_FILES = COPYING
|
||||
# No license file included in pip, but it's present on github
|
||||
PYTHON_PYMUPDF_DEPENDENCIES = freetype host-swig mupdf
|
||||
PYTHON_PYMUPDF_BUILD_OPTS = --skip-dependency-check
|
||||
|
||||
PYTHON_PYMUPDF_ENV = \
|
||||
PYMUPDF_INCLUDES="$(STAGING_DIR)/usr/include/freetype2:$(STAGING_DIR)/usr/include" \
|
||||
PYMUPDF_MUPDF_LIB="$(STAGING_DIR)/usr/lib" \
|
||||
PYMUPDF_PYTHON_CONFIG="$(STAGING_DIR)/usr/bin/python3-config" \
|
||||
PYMUPDF_SETUP_IMPLEMENTATIONS=a \
|
||||
PYMUPDF_SETUP_MUPDF_BUILD=
|
||||
|
||||
$(eval $(python-package))
|
||||
Reference in New Issue
Block a user