diff --git a/graphviz_14-0-0.patch b/graphviz_14-0-0.patch index 61e41c0..90aa1a2 100644 --- a/graphviz_14-0-0.patch +++ b/graphviz_14-0-0.patch @@ -1,88 +1,42 @@ --- - pygraphviz/graphviz.i | 5 +++++ - setup.py | 41 +++++++++++++++++++++++++++++++++++++++-- - 2 files changed, 44 insertions(+), 2 deletions(-) + pygraphviz/graphviz_wrap.c | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) -Index: pygraphviz-1.14/pygraphviz/graphviz.i +Index: pygraphviz-1.14/pygraphviz/graphviz_wrap.c =================================================================== ---- pygraphviz-1.14.orig/pygraphviz/graphviz.i 2024-09-29 20:31:00.000000000 +0200 -+++ pygraphviz-1.14/pygraphviz/graphviz.i 2025-10-23 00:14:21.676670665 +0200 -@@ -338,7 +338,12 @@ - /* three lines are straight from the SWIG manual. */ - %include - %include -+#if GRAPHVIZ_VERSION_MAJOR >= 14 -+%cstring_output_allocate_size(char **result, size_t* size, free(*$1)); -+int gvRenderData(GVC_t *gvc, Agraph_t* g, char *format, char **result, size_t *size); -+#else - %cstring_output_allocate_size(char **result, unsigned int* size, free(*$1)); - int gvRenderData(GVC_t *gvc, Agraph_t* g, char *format, char **result, unsigned int *size); +--- pygraphviz-1.14.orig/pygraphviz/graphviz_wrap.c 2024-09-29 20:31:00.000000000 +0200 ++++ pygraphviz-1.14/pygraphviz/graphviz_wrap.c 2025-10-24 18:49:18.399642610 +0200 +@@ -3022,6 +3022,11 @@ + + #include "graphviz/cgraph.h" + #include "graphviz/gvc.h" ++#include "graphviz/graphviz_version.h" ++ ++#ifndef GRAPHVIZ_VERSION_MAJOR ++#define GRAPHVIZ_VERSION_MAJOR 12 +#endif - /* Free memory allocated and pointed to by *result in gvRenderData */ - extern void gvFreeRenderData (char* data); -Index: pygraphviz-1.14/setup.py -=================================================================== ---- pygraphviz-1.14.orig/setup.py 2024-09-29 20:31:00.000000000 +0200 -+++ pygraphviz-1.14/setup.py 2025-10-23 00:45:39.447285598 +0200 -@@ -1,15 +1,51 @@ - import sys -+import os -+import re - from setuptools import setup, Extension -+def get_graphviz_version(): -+ """ -+ Reads GRAPHVIZ_VERSION_MAJOR from the header file. -+ Assumes the header is available at a known path during setup. -+ """ -+ # NOTE: You may need to adjust this path based on your environment -+ # or rely on the build system to have already installed it. -+ header_path = '/usr/include/graphviz/graphviz_version.h' -+ -+ if not os.path.exists(header_path): -+ # Fallback/default if header file cannot be read during setup. -+ # This should match your expected target version. -+ raise RuntimeError(f"Graphviz header file not found at {header_path}.") -+ -+ with open(header_path, 'r') as f: -+ content = f.read() -+ match = re.search(r'#define\s+GRAPHVIZ_VERSION_MAJOR\s+(\d+)', content) -+ if match: -+ return int(match.group(1)) -+ else: -+ match = re.search(r'#define\s+PACKAGE_VERSION\s+"([0-9.]+)"', content) -+ if match: -+ maj_ver = match.group(1).split('.')[0] -+ return int(maj_ver) -+ -+ raise RuntimeError(f"GRAPHVIZ_VERSION_MAJOR macro not found in the header file!") -+ - if __name__ == "__main__": -- define_macros = [("SWIG_PYTHON_STRICT_BYTE_CHAR", None)] -+ # Get the target version number -+ gv_major_version = get_graphviz_version() -+ -+ define_macros = [] -+ swig_options = [] - if sys.platform == "win32": - define_macros.append(("GVDLL", None)) - -+ swig_options.append("-DGRAPHVIZ_VERSION_MAJOR={}".format(str(gv_major_version))) -+ print(f"Defining GRAPHVIZ_VERSION_MAJOR as: {gv_major_version}") -+ - extension = [ - Extension( - name="pygraphviz._graphviz", -- sources=["pygraphviz/graphviz_wrap.c"], -+ sources=["pygraphviz/graphviz.i"], - include_dirs=[], - library_dirs=[], - # cdt does not link to cgraph, whereas cgraph links to cdt. -@@ -20,6 +56,7 @@ - # undefined symbol errors. seen under PyPy on Linux.) - libraries=["cdt", "cgraph", "gvc"], - define_macros=define_macros, -+ swig_opts=swig_options, - ) - ] + SWIGINTERN swig_type_info* +@@ -5447,7 +5452,13 @@ + Agraph_t *arg2 = (Agraph_t *) 0 ; + char *arg3 = (char *) 0 ; + char **arg4 = (char **) 0 ; ++#if GRAPHVIZ_VERSION_MAJOR >= 14 ++ size_t *arg5 = (size_t *) 0 ; ++ size_t tempn4 ; ++#else + unsigned int *arg5 = (unsigned int *) 0 ; ++ unsigned int tempn4 ; ++#endif + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; +@@ -5456,7 +5467,6 @@ + char *buf3 = 0 ; + int alloc3 = 0 ; + char *temp4 = 0 ; +- unsigned int tempn4 ; + PyObject *swig_obj[3] ; + int result; + diff --git a/python-pygraphviz.changes b/python-pygraphviz.changes index a3480e4..d592074 100644 --- a/python-pygraphviz.changes +++ b/python-pygraphviz.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri Oct 24 16:52:44 UTC 2025 - Matej Cepl + +- More gentle version of graphviz_14-0-0.patch, which doesn’t + change a SWIG include file, just the C generated one with the + minimal required change (bsc#1252488). + ------------------------------------------------------------------- Wed Oct 22 17:55:37 UTC 2025 - Matej Cepl diff --git a/python-pygraphviz.spec b/python-pygraphviz.spec index 9dfcd7b..d5e7cb7 100644 --- a/python-pygraphviz.spec +++ b/python-pygraphviz.spec @@ -78,9 +78,6 @@ This package provides documentation and help files for %{name} %autosetup -p1 -n pygraphviz-%{version} cp %SOURCE1 examples -# Remove generated C file to force regeneration from SWIG sources -rm pygraphviz/graphviz_wrap.c - %build export CFLAGS="%{optflags}" %if ! %{with doc}