14
0

- 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).

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pygraphviz?expand=0&rev=38
This commit is contained in:
2025-10-24 16:53:54 +00:00
committed by Git OBS Bridge
parent 4eb6f121f1
commit b2133b1b9e
3 changed files with 43 additions and 85 deletions

View File

@@ -1,88 +1,42 @@
--- ---
pygraphviz/graphviz.i | 5 +++++ pygraphviz/graphviz_wrap.c | 12 +++++++++++-
setup.py | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 11 insertions(+), 1 deletion(-)
2 files changed, 44 insertions(+), 2 deletions(-)
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.orig/pygraphviz/graphviz_wrap.c 2024-09-29 20:31:00.000000000 +0200
+++ pygraphviz-1.14/pygraphviz/graphviz.i 2025-10-23 00:14:21.676670665 +0200 +++ pygraphviz-1.14/pygraphviz/graphviz_wrap.c 2025-10-24 18:49:18.399642610 +0200
@@ -338,7 +338,12 @@ @@ -3022,6 +3022,11 @@
/* three lines are straight from the SWIG manual. */
%include <cstring.i> #include "graphviz/cgraph.h"
%include <typemaps.i> #include "graphviz/gvc.h"
+#if GRAPHVIZ_VERSION_MAJOR >= 14 +#include "graphviz/graphviz_version.h"
+%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); +#ifndef GRAPHVIZ_VERSION_MAJOR
+#else +#define GRAPHVIZ_VERSION_MAJOR 12
%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);
+#endif +#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))) SWIGINTERN swig_type_info*
+ print(f"Defining GRAPHVIZ_VERSION_MAJOR as: {gv_major_version}") @@ -5447,7 +5452,13 @@
+ Agraph_t *arg2 = (Agraph_t *) 0 ;
extension = [ char *arg3 = (char *) 0 ;
Extension( char **arg4 = (char **) 0 ;
name="pygraphviz._graphviz", +#if GRAPHVIZ_VERSION_MAJOR >= 14
- sources=["pygraphviz/graphviz_wrap.c"], + size_t *arg5 = (size_t *) 0 ;
+ sources=["pygraphviz/graphviz.i"], + size_t tempn4 ;
include_dirs=[], +#else
library_dirs=[], unsigned int *arg5 = (unsigned int *) 0 ;
# cdt does not link to cgraph, whereas cgraph links to cdt. + unsigned int tempn4 ;
@@ -20,6 +56,7 @@ +#endif
# undefined symbol errors. seen under PyPy on Linux.) void *argp1 = 0 ;
libraries=["cdt", "cgraph", "gvc"], int res1 = 0 ;
define_macros=define_macros, void *argp2 = 0 ;
+ swig_opts=swig_options, @@ -5456,7 +5467,6 @@
) char *buf3 = 0 ;
] int alloc3 = 0 ;
char *temp4 = 0 ;
- unsigned int tempn4 ;
PyObject *swig_obj[3] ;
int result;

View File

@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Oct 24 16:52:44 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
- More gentle version of graphviz_14-0-0.patch, which doesnt
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 <mcepl@cepl.eu> Wed Oct 22 17:55:37 UTC 2025 - Matej Cepl <mcepl@cepl.eu>

View File

@@ -78,9 +78,6 @@ This package provides documentation and help files for %{name}
%autosetup -p1 -n pygraphviz-%{version} %autosetup -p1 -n pygraphviz-%{version}
cp %SOURCE1 examples cp %SOURCE1 examples
# Remove generated C file to force regeneration from SWIG sources
rm pygraphviz/graphviz_wrap.c
%build %build
export CFLAGS="%{optflags}" export CFLAGS="%{optflags}"
%if ! %{with doc} %if ! %{with doc}