File mayavi-pr1364-vtk9.5.patch of Package mayavi
From 9a12eb13add3599f12bc3252852c11cc66eec6fb Mon Sep 17 00:00:00 2001
From: Eric Larson <larson.eric.d@gmail.com>
Date: Fri, 10 Oct 2025 11:29:20 -0400
Subject: [PATCH] WIP: Support 9.5.2
---
tvtk/vtk_parser.py | 5 ++++-
tvtk/wrapper_gen.py | 19 +++++++++++++++----
2 files changed, 19 insertions(+), 5 deletions(-)
Index: mayavi-4.8.3/tvtk/vtk_parser.py
===================================================================
--- mayavi-4.8.3.orig/tvtk/vtk_parser.py
+++ mayavi-4.8.3/tvtk/vtk_parser.py
@@ -644,7 +644,10 @@ class VTKMethodParser:
# These hang on Windows (and maybe Fedora 34)
elif (klass_name in ('vtkDataEncoder', 'vtkWebApplication')):
continue
- # we can actually process it
+ # On VTK 9.5.2 we get
+ # Cannot set the undefined 'copy_global_ids' attribute of a 'PointData' object
+ elif (klass_name == "vtkDataSetAttributes" and method[3:] in ("CopyGlobalIds", "CopyNormals", "CopyPedigreeIds", "CopyScalars", "CopyTCoords", "CopyTensors", "CopyVectors")):
+ continue
elif ('Get' + method[3:]) in methods:
key = method[3:]
meths.remove('Set' + key)
Index: mayavi-4.8.3/tvtk/wrapper_gen.py
===================================================================
--- mayavi-4.8.3.orig/tvtk/wrapper_gen.py
+++ mayavi-4.8.3/tvtk/wrapper_gen.py
@@ -149,17 +149,27 @@ def patch_default(vtk_get_meth, vtk_set_
# Collect the signatures of the get method
# We only use the arguments
- all_sigs = vtk_parser.VTKMethodParser.get_method_signature(vtk_get_meth)
+ # TODO: Unclear why this would be used... but for example if the Get method
+ # takes a string as an argument, we don't want that to be what we expect the
+ # *output* to be (which can be for example vtkDataArray*). But presumably
+ # this was here for a reason so let's just add exceptions for things that are
+ # known to be problematic on VTK 9.5.2...
+ all_sigs = []
+ #if vtk_get_meth.__name__ not in ("GetGlobalIds", "GetHigherOrderDegrees", "GetNormals", "GetPedigreeIds", "GetProcessIds", "GetRationalWeights", "GetScalars", "GetTCoords", "GetTensors", "GetVectors", "GetTangents"):
+ # all_sigs.extend(
+ # vtk_parser.VTKMethodParser.get_method_signature(vtk_get_meth)
+ # )
# Collect the signatures of the set method
all_sigs.extend(
- vtk_parser.VTKMethodParser.get_method_signature(vtk_set_meth))
+ vtk_parser.VTKMethodParser.get_method_signature(vtk_set_meth)
+ )
for sig in all_sigs:
if sig[1] is None:
continue
- if len(sig[1]) == 1:
+ if len(sig[1]) == 1 and not isinstance(sig[1][0], str):
# This unpacks tuple of something e.g. (('int', 'int', 'int'))
arg_formats.append(tuple(chain.from_iterable(sig[1])))
@@ -168,9 +178,10 @@ def patch_default(vtk_get_meth, vtk_set_
default_mappings = {
'int' : 0,
'float': 0.0,
- 'string': ''
+ 'string': '',
}
+ # vtkDataArray shows up but isn't used... causes problems
for arg_format in arg_formats:
try:
all_same_type = len(set(arg_format)) == 1
Index: mayavi-4.8.3/tvtk/tests/test_vtk_parser.py
===================================================================
--- mayavi-4.8.3.orig/tvtk/tests/test_vtk_parser.py
+++ mayavi-4.8.3/tvtk/tests/test_vtk_parser.py
@@ -29,6 +29,7 @@ _cache = vtk_parser.VTKMethodParser()
class TestVTKParser(unittest.TestCase):
def setUp(self):
self.p = _cache
+ self.maxDiff = None
def test_methods(self):
"""Check get_methods."""
@@ -135,6 +136,9 @@ class TestVTKParser(unittest.TestCase):
res['SelectionPointSize'] = (2.0, None)
if (vtk_major_version, vtk_minor_version) >= (9, 3):
res['EdgeOpacity'] = (1.0, None)
+ if (vtk_major_version, vtk_minor_version) >= (9, 5):
+ res['EdgeWidth'] = (1.0, (0.0, float_max))
+ res['Point2DShape'] = (1, None)
result = list(p.get_get_set_methods().keys())
if hasattr(obj, 'GetTexture'):
@@ -175,16 +179,18 @@ class TestVTKParser(unittest.TestCase):
'RemoveTexture', 'Render']
res.extend(['SetBaseColorTexture', 'SetEmissiveTexture',
'SetNormalTexture', 'SetORMTexture'])
- if vtk_major_version == 9 and vtk_minor_version > 0:
+ if (vtk_major_version, vtk_minor_version) >= (9, 0):
res.extend([
'ComputeIORFromReflectance', 'ComputeReflectanceFromIOR',
'ComputeReflectanceOfBaseLayer', 'SetAnisotropyTexture',
'SetCoatNormalTexture'
])
+ if (vtk_major_version, vtk_minor_version) >= (9, 5):
+ res.extend(['Point2DShapeType'])
if hasattr(obj, 'PostRender'):
res.append('PostRender')
- res.sort()
+ res.sort()
self.assertEqual(p.get_other_methods(), res)
self.assertEqual(p.other_meths, p.get_other_methods())
Index: mayavi-4.8.3/tvtk/tests/test_tvtk.py
===================================================================
--- mayavi-4.8.3.orig/tvtk/tests/test_tvtk.py
+++ mayavi-4.8.3/tvtk/tests/test_tvtk.py
@@ -828,12 +828,14 @@ class TestTVTKModule(unittest.TestCase):
tvtk_name = get_tvtk_name(name)
tvtk_klass = getattr(tvtk, tvtk_name, None)
if on_gha:
- print(tvtk_name)
+ print(tvtk_name + " ... ", end='', flush=True)
try:
tvtk_klass()
# TypeError: super(type, obj): obj must be an instance or subtype of type
except (TraitError, KeyError, TypeError):
errors.append(f"\n{name}:\n{indent(traceback.format_exc(), ' ')}")
+ else:
+ print("ok")
if on_gha:
print("\n::endgroup::")
if len(errors) > 0:
@@ -935,6 +937,9 @@ class TestTVTKModule(unittest.TestCase):
trait = getattr(obj, trait_name)
except (TypeError, TraitError):
pass # this is tested in another test
+ except AttributeError:
+ raise ValueError(f"AttributeError {trait_name=} not found in {obj.__dict__}"
+ f"of {tvtk_klass_name=}, {name=}")
else:
if isinstance(trait, str) and trait.endswith('_p_void'):
errors_trait_is_ptr.append(