git: 5cd304ce77d4 - main - devel/py-lxml5: Allow build with cython 3.1.0+

From: Po-Chuan Hsieh <sunpoet_at_FreeBSD.org>
Date: Thu, 26 Jun 2025 11:32:15 UTC
The branch main has been updated by sunpoet:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5cd304ce77d495eb41f0fd060fc79bc3d90d0f23

commit 5cd304ce77d495eb41f0fd060fc79bc3d90d0f23
Author:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
AuthorDate: 2025-06-26 09:59:58 +0000
Commit:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
CommitDate: 2025-06-26 11:29:45 +0000

    devel/py-lxml5: Allow build with cython 3.1.0+
    
    - Bump PORTREVISION for package change
    
    Obtained from:  https://github.com/lxml/lxml/commit/6a0f0f09e26d574e75848d0ca1ef00e97ee49658
                    https://github.com/lxml/lxml/commit/99c81a6694f92dd09626f861f313505ab667b948
---
 devel/py-lxml5/Makefile                   |  1 +
 devel/py-lxml5/files/patch-cython         | 49 +++++++++++++++++++++++++++++++
 devel/py-lxml5/files/patch-pyproject.toml |  9 ++++++
 3 files changed, 59 insertions(+)

diff --git a/devel/py-lxml5/Makefile b/devel/py-lxml5/Makefile
index 1b03b597d4f6..1affaf7740ff 100644
--- a/devel/py-lxml5/Makefile
+++ b/devel/py-lxml5/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	lxml
 PORTVERSION=	5.4.0
+PORTREVISION=	1
 CATEGORIES=	devel python
 MASTER_SITES=	PYPI \
 		https://github.com/lxml/lxml/releases/download/lxml-${PORTVERSION}/
diff --git a/devel/py-lxml5/files/patch-cython b/devel/py-lxml5/files/patch-cython
new file mode 100644
index 000000000000..8e0de0845e51
--- /dev/null
+++ b/devel/py-lxml5/files/patch-cython
@@ -0,0 +1,49 @@
+Obtained from:	https://github.com/lxml/lxml/commit/6a0f0f09e26d574e75848d0ca1ef00e97ee49658
+		https://github.com/lxml/lxml/commit/99c81a6694f92dd09626f861f313505ab667b948
+
+--- setupinfo.py.orig	2025-04-22 12:23:54 UTC
++++ setupinfo.py
+@@ -176,34 +176,6 @@ def ext_modules(static_include_dirs, static_library_di
+         from Cython.Build import cythonize
+         result = cythonize(result, compiler_directives=cythonize_directives)
+ 
+-        # Fix compiler warning due to missing pragma-push in Cython 3.0.9.
+-        for ext in result:
+-            for source_file in ext.sources:
+-                if not source_file.endswith('.c'):
+-                    continue
+-                with open(source_file, 'rb') as f:
+-                    lines = f.readlines()
+-                if b'Generated by Cython 3.0.9' not in lines[0]:
+-                    continue
+-
+-                modified = False
+-                temp_file = source_file + ".tmp"
+-                with open(temp_file, 'wb') as f:
+-                    last_was_push = False
+-                    for line in lines:
+-                        if b'#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"' in line and not last_was_push:
+-                            f.write(b"#pragma GCC diagnostic push\n")
+-                            modified = True
+-                        last_was_push = b'#pragma GCC diagnostic push' in line
+-                        f.write(line)
+-
+-                if modified:
+-                    print("Fixed Cython 3.0.9 generated source file " + source_file)
+-                    os.unlink(source_file)
+-                    os.rename(temp_file, source_file)
+-                else:
+-                    os.unlink(temp_file)
+-
+     # for backwards compatibility reasons, provide "etree[_api].h" also as "lxml.etree[_api].h"
+     for header_filename in HEADER_FILES:
+         src_file = os.path.join(SOURCE_PATH, 'lxml', header_filename)
+@@ -367,6 +339,8 @@ def define_macros():
+         macros.append(('LXML_UNICODE_STRINGS', '1'))
+     if OPTION_WITH_COVERAGE:
+         macros.append(('CYTHON_TRACE_NOGIL', '1'))
++        # coverage.py does not support Cython together with sys.monitoring.
++        macros.append(('CYTHON_USE_SYS_MONITORING', '0'))
+     if OPTION_BUILD_LIBXML2XSLT:
+         macros.append(('LIBXML_STATIC', None))
+         macros.append(('LIBXSLT_STATIC', None))
diff --git a/devel/py-lxml5/files/patch-pyproject.toml b/devel/py-lxml5/files/patch-pyproject.toml
new file mode 100644
index 000000000000..acf2d2f5a6ab
--- /dev/null
+++ b/devel/py-lxml5/files/patch-pyproject.toml
@@ -0,0 +1,9 @@
+--- pyproject.toml.orig	2025-04-22 12:23:54 UTC
++++ pyproject.toml
+@@ -1,5 +1,5 @@
+ [build-system]
+-requires = ["Cython>=3.0.11, < 3.1.0", "setuptools", "wheel"]
++requires = ["Cython>=3.1.0", "setuptools", "wheel"]
+ 
+ [tool.cibuildwheel]
+ build-verbosity = 1