Files
rpi-buildroot/package/python-pymupdf/0001-pipcl.py-allow-providing-python-config-externally.patch
James Hilliard 9b9333c929 package/python-pymupdf: bump to version 1.23.22
The python-pymupdf and mupdf packages do not follow the exact same
version numbers anymore. There is no specific mention of version
compatibilities in the upstream package, so update our comment to just
say that both should be "compatible" (to try to avoid one being
updated without the other).

The hardcoded paths we used to remove from setup.py are no longer
present, so the post-patch hook is removed.  The new setup.py instead
uses new environment variables which we now provide.

This new python-pymupdf version fails at runtime when mupdf builds
static libraries.

Note also that python-pymupdf is gradually switching to a new
implementation that requires mupdf to be built with python
bindings. For now, both implementations are still available but we
only compile the old one. The runtime test is adapted accordingly as
the legacy implementation has to be imported with "fitz_old".

While at it, the dependencies are also split to one per line to make
them easier to diff in the future.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
[Raphaël:
 - fix cross-compilation
 - remove unneeded dependencies
 - update to 1.23.22
 - update the commit message
]
Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2024-07-13 21:55:26 +02:00

126 lines
5.6 KiB
Diff

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