Page MenuHomeFreeBSD
Paste P674

Command-Line Input
ActivePublic

Authored by ngie on Sun, Oct 19, 7:11 AM.
Tags
None
Referenced Files
F132715074: Command-Line Input
Sun, Oct 19, 7:11 AM
Subscribers
None
diff --git a/print/py-PyMuPDF/Makefile b/print/py-PyMuPDF/Makefile
index e0e3bd6a6afc..78f4f8dda5ad 100644
--- a/print/py-PyMuPDF/Makefile
+++ b/print/py-PyMuPDF/Makefile
@@ -1,6 +1,6 @@
PORTNAME= PyMuPDF
-PORTVERSION= 1.22.5
-PORTREVISION= 1
+PORTVERSION= 1.26.5
+DISTNAME= pymupdf-${PORTVERSION}
CATEGORIES= print python
MASTER_SITES= PYPI
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
@@ -13,9 +13,17 @@ LICENSE= AGPLv3
LICENSE_FILE= ${WRKSRC}/COPYING
BUILD_DEPENDS= bash:shells/bash \
+ mupdf:graphics/mupdf \
+ ${PYTHON_PKGNAMEPREFIX}clang>0:devel/py-clang@${PY_FLAVOR} \
swig:devel/swig
+RUN_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}clang>0:devel/py-clang@${PY_FLAVOR} \
+ mupdf:graphics/mupdf
USES= gmake python
-USE_PYTHON= autoplist concurrent distutils
+USE_PYTHON= autoplist concurrent pep517
+
+MAKE_ENV+= PYMUPDF_SETUP_LIBCLANG="clang" \
+ PYMUPDF_SETUP_MUPDF_BUILD="" \
+ PYMUPDF_SETUP_MUPDF_TGZ=""
.include <bsd.port.mk>
diff --git a/print/py-PyMuPDF/distinfo b/print/py-PyMuPDF/distinfo
index 6afed7c3ad0f..ad2275406b73 100644
--- a/print/py-PyMuPDF/distinfo
+++ b/print/py-PyMuPDF/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1687397187
-SHA256 (PyMuPDF-1.22.5.tar.gz) = 5ec8d5106752297529d0d68d46cfc4ce99914aabd99be843f1599a1842d63fe9
-SIZE (PyMuPDF-1.22.5.tar.gz) = 61638053
+TIMESTAMP = 1760817403
+SHA256 (pymupdf-1.26.5.tar.gz) = 8ef335e07f648492df240f2247854d0e7c0467afb9c4dc2376ec30978ec158c3
+SIZE (pymupdf-1.26.5.tar.gz) = 84319274
diff --git a/print/py-PyMuPDF/files/patch-mupdf-1.26.10-source_scripts_wrap_____main____.py b/print/py-PyMuPDF/files/patch-mupdf-1.26.10-source_scripts_wrap_____main____.py
new file mode 100644
index 000000000000..562013dacd5d
--- /dev/null
+++ b/print/py-PyMuPDF/files/patch-mupdf-1.26.10-source_scripts_wrap_____main____.py
@@ -0,0 +1,14 @@
+--- mupdf-1.26.10-source/scripts/wrap/__main__.py.orig 2025-10-19 06:40:25 UTC
++++ mupdf-1.26.10-source/scripts/wrap/__main__.py
+@@ -1077,7 +1077,10 @@ def _get_m_command( build_dirs, j=None, make=None, m_t
+ if make:
+ jlib.log('Overriding from $MUPDF_MAKE: {make=}.')
+ if not make:
+- if state.state_.openbsd:
++ if state.state_.freebsd:
++ make = 'CXX=c++ gmake'
++ jlib.log('FreeBSD, using: {make=}.')
++ elif state.state_.openbsd:
+ # Need to run gmake, not make. Also for some
+ # reason gmake on OpenBSD sets CC to clang, but
+ # CXX to g++, so need to force CXX=c++ too.
diff --git a/print/py-PyMuPDF/files/patch-mupdf-1.26.10-source_scripts_wrap_state.py b/print/py-PyMuPDF/files/patch-mupdf-1.26.10-source_scripts_wrap_state.py
new file mode 100644
index 000000000000..b16f7561f7e8
--- /dev/null
+++ b/print/py-PyMuPDF/files/patch-mupdf-1.26.10-source_scripts_wrap_state.py
@@ -0,0 +1,14 @@
+--- mupdf-1.26.10-source/scripts/wrap/state.py.orig 2025-10-19 06:47:10 UTC
++++ mupdf-1.26.10-source/scripts/wrap/state.py
+@@ -68,9 +68,10 @@ class State:
+ self.os_name = platform.system()
+ self.windows = (self.os_name == 'Windows' or self.os_name.startswith('CYGWIN'))
+ self.cygwin = self.os_name.startswith('CYGWIN')
+- self.openbsd = self.os_name == 'OpenBSD'
++ self.freebsd = self.os_name == 'FreeBSD'
+ self.linux = self.os_name == 'Linux'
+ self.macos = self.os_name == 'Darwin'
++ self.openbsd = self.os_name == 'OpenBSD'
+ self.pyodide = os.environ.get('OS') == 'pyodide'
+ self.have_done_build_0 = False
+
diff --git a/print/py-PyMuPDF/files/patch-setup.py b/print/py-PyMuPDF/files/patch-setup.py
new file mode 100644
index 000000000000..42c7b9c72f7a
--- /dev/null
+++ b/print/py-PyMuPDF/files/patch-setup.py
@@ -0,0 +1,20 @@
+--- setup.py.orig 2025-10-10 10:57:59 UTC
++++ setup.py
+@@ -726,7 +726,7 @@ def build():
+ log(f'Failed to get git information: {e}')
+ sha, comment, diff, branch = (None, None, None, None)
+ swig = PYMUPDF_SETUP_SWIG or 'swig'
+- swig_version_text = run(f'{swig} --version', capture=1)
++ swig_version_text = run(f'{swig} -version', capture=1)
+ m = re.search('\nSWIG Version ([^\n]+)', swig_version_text)
+ log(f'{swig_version_text=}')
+ assert m, f'Unrecognised {swig_version_text=}'
+@@ -1409,6 +1409,8 @@ else:
+ print(f'msys2: pip install of swig does not build; assuming `pacman -S swig`.')
+ elif openbsd:
+ print(f'OpenBSD: pip install of swig does not build; assuming `pkg_add swig`.')
++ elif freebsd:
++ pass
+ else:
+ ret.append( 'swig')
+ return ret

Event Timeline

Fails to build with the error seen below.
Not specifying PYMUPDF_SETUP_MUPDF_BUILD results in another error after the package tries to build MuPDF from scratch when building components with gmake. The build system is very complex. I feel like they need to use a different build infrastructure/tool than setuptools (cmake?) and they're going way too deep trying to get the build to work within the confines of setuptools, pip, etc.

^[[1m<...>/freebsd-ports/print/py-PyMuPDF/work-py311/pymupdf-1.26.5/src/build/extra.i.cpp:3346:10: ^[[0m^[[0;1;31mfatal error: ^[[0m^[[1m'mupdf/classes2.h' file not found^[[0m^M
 3346 | #include ^[[0;32m"mupdf/classes2.h"^[[0m^M
      | ^[[0;1;32m         ^~~~~~~~~~~~~~~~~~^M                                                                     
^[[0m1 error generated.^M                            
Traceback (most recent call last):^M                                                    
  File "/usr/local/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>^M
    main()^M                                                  
  File "/usr/local/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 373, in main^M
    json_out["return_val"] = hook(**hook_input["kwargs"])^M                                                                                                                          
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^M          
  File "/usr/local/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 280, in build_wheel^M                                        
    return _build_backend().build_wheel(^M                                                                               
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^M                               
  File "<...>/freebsd-ports/print/py-PyMuPDF/work-py311/pymupdf-1.26.5/pipcl.py", line 721, in build_wheel^M             
    items = self._call_fn_build(config_settings)^M
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^M
  File "<...>/freebsd-ports/print/py-PyMuPDF/work-py311/pymupdf-1.26.5/pipcl.py", line 1017, in _call_fn_build^M             
    ret = self.fn_build()^M                         
          ^^^^^^^^^^^^^^^^M                
  File "<...>/freebsd-ports/print/py-PyMuPDF/work-py311/pymupdf-1.26.5/setup.py", line 634, in build^M             
    path_so_leaf = _build_extension(^M                               
                   ^^^^^^^^^^^^^^^^^^M                           
  File "<...>/freebsd-ports/print/py-PyMuPDF/work-py311/pymupdf-1.26.5/setup.py", line 1108, in _build_extension^M             
    path_so_leaf = pipcl.build_extension(^M                         
                   ^^^^^^^^^^^^^^^^^^^^^^^M
  File "<...>/freebsd-ports/print/py-PyMuPDF/work-py311/pymupdf-1.26.5/pipcl.py", line 1867, in build_extension^M             
    run_if(^M                            
  File "<...>/freebsd-ports/print/py-PyMuPDF/work-py311/pymupdf-1.26.5/pipcl.py", line 2816, in run_if^M             
    run( command, caller=caller+1)^M     
  File "<...>/freebsd-ports/print/py-PyMuPDF/work-py311/pymupdf-1.26.5/pipcl.py", line 2385, in run^M             
    cp = subprocess.run(^M                                                                                            
         ^^^^^^^^^^^^^^^^M                                                                         
  File "/usr/local/lib/python3.11/subprocess.py", line 571, in run^M
    raise CalledProcessError(retcode, process.args,^M
subprocess.CalledProcessError: Command '$CXX \^M
    -fPIC \^M                                         
    -O2 -DNDEBUG \^M                                
    -I/usr/local/include/python3.11 -I/usr/local/include/python3.11 \^M
    -MD -MF <...>/freebsd-ports/print/py-PyMuPDF/work-py311/pymupdf-1.26.5/src/build/extra.i.cpp.o.d \^M
    -c <...>/freebsd-ports/print/py-PyMuPDF/work-py311/pymupdf-1.26.5/src/build/extra.i.cpp \^M
    -o <...>/freebsd-ports/print/py-PyMuPDF/work-py311/pymupdf-1.26.5/src/build/extra.i.cpp.o \^M
     -Wall -Wno-deprecated-declarations -Wno-unused-const-variable -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing  -O2 -pipe -fstack-protector-strong -fno-strict-aliasing \^M
    -DPy_LIMITED_API=0x030b0000' returned non-zero exit status 1.^M                                                                   
^M                                                                                                                                                                                                        
^[[91mERROR^[[0m Backend subprocess exited when trying to invoke build_wheel^M
*** Error code 1^M                                                                                               
^M                                                            
Stop.^M                                                     
make: stopped in <...>/freebsd-ports/print/py-PyMuPDF^M
                                               
Command exit status: 1
Script done on Sun Oct 19 00:02:48 2025