Add upstream patch to support Python 3.8

This commit is contained in:
Orion Poplawski 2019-08-20 19:40:13 -06:00
parent d727be173a
commit 2639d96baa
3 changed files with 183 additions and 43 deletions

View File

@ -1,40 +0,0 @@
From 706f1b397df09a27ab8981ab9464547028d0c322 Mon Sep 17 00:00:00 2001
From: David Gobbi <david.gobbi@gmail.com>
Date: Wed, 11 Jul 2018 17:14:50 -0600
Subject: [PATCH] Fix compilation issue due to Python3.7 API change
The PyUnicode_AsUTF8() method returns a "const char *" in Py37.
---
Wrapping/PythonCore/vtkPythonArgs.cxx | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/Wrapping/PythonCore/vtkPythonArgs.cxx b/Wrapping/PythonCore/vtkPythonArgs.cxx
index 1a82af0802..b733458975 100644
--- a/Wrapping/PythonCore/vtkPythonArgs.cxx
+++ b/Wrapping/PythonCore/vtkPythonArgs.cxx
@@ -95,13 +95,21 @@ bool vtkPythonGetStringValue(PyObject *o, T *&a, const char *exctext)
{
if (PyBytes_Check(o))
{
+#if PY_VERSION_HEX >= 0x03070000
+ a = const_cast<char *>(PyBytes_AS_STRING(o));
+ return true;
+#else
a = PyBytes_AS_STRING(o);
return true;
+#endif
}
#ifdef Py_USING_UNICODE
else if (PyUnicode_Check(o))
{
-#if PY_VERSION_HEX >= 0x03030000
+#if PY_VERSION_HEX >= 0x03070000
+ a = const_cast<char *>(PyUnicode_AsUTF8(o));
+ return true;
+#elif PY_VERSION_HEX >= 0x03030000
a = PyUnicode_AsUTF8(o);
return true;
#else
--
2.18.1

176
5883.patch Normal file
View File

@ -0,0 +1,176 @@
From 257b9d7b18d5f3db3fe099dc18f230e23f7dfbab Mon Sep 17 00:00:00 2001
From: David Gobbi <david.gobbi@gmail.com>
Date: Tue, 20 Aug 2019 17:02:24 -0600
Subject: [PATCH] Compatibility for Python 3.8
The PyTypeObject struct was modified in Python 3.8, this change is
required to avoid compile errors.
---
.../PythonInterpreter/vtkPythonStdStreamCaptureHelper.h | 6 ++++++
Wrapping/PythonCore/PyVTKMethodDescriptor.cxx | 2 +-
Wrapping/PythonCore/PyVTKNamespace.cxx | 2 +-
Wrapping/PythonCore/PyVTKReference.cxx | 8 ++++----
Wrapping/PythonCore/PyVTKTemplate.cxx | 2 +-
Wrapping/PythonCore/vtkPythonCompatibility.h | 8 +++++++-
Wrapping/Tools/vtkWrapPythonClass.c | 2 +-
Wrapping/Tools/vtkWrapPythonEnum.c | 2 +-
Wrapping/Tools/vtkWrapPythonType.c | 2 +-
9 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/Utilities/PythonInterpreter/vtkPythonStdStreamCaptureHelper.h b/Utilities/PythonInterpreter/vtkPythonStdStreamCaptureHelper.h
index b1c12c83de..14ccfbe928 100644
--- a/Utilities/PythonInterpreter/vtkPythonStdStreamCaptureHelper.h
+++ b/Utilities/PythonInterpreter/vtkPythonStdStreamCaptureHelper.h
@@ -140,6 +140,12 @@ static PyTypeObject vtkPythonStdStreamCaptureHelperType = {
#if PY_VERSION_HEX >= 0x03040000
0, // tp_finalize
#endif
+#if PY_VERSION_HEX >= 0x03080000
+ 0, // tp_vectorcall
+#if PY_VERSION_HEX < 0x03090000
+ 0, // tp_print
+#endif
+#endif
};
static PyObject* vtkWrite(PyObject* self, PyObject* args)
diff --git a/Wrapping/PythonCore/PyVTKMethodDescriptor.cxx b/Wrapping/PythonCore/PyVTKMethodDescriptor.cxx
index 2b0d443537..3840038498 100644
--- a/Wrapping/PythonCore/PyVTKMethodDescriptor.cxx
+++ b/Wrapping/PythonCore/PyVTKMethodDescriptor.cxx
@@ -186,7 +186,7 @@ PyTypeObject PyVTKMethodDescriptor_Type = {
sizeof(PyMethodDescrObject), // tp_basicsize
0, // tp_itemsize
PyVTKMethodDescriptor_Delete, // tp_dealloc
- nullptr, // tp_print
+ 0, // tp_vectorcall_offset
nullptr, // tp_getattr
nullptr, // tp_setattr
nullptr, // tp_compare
diff --git a/Wrapping/PythonCore/PyVTKNamespace.cxx b/Wrapping/PythonCore/PyVTKNamespace.cxx
index 71ee2a3516..5cf5bfbe6b 100644
--- a/Wrapping/PythonCore/PyVTKNamespace.cxx
+++ b/Wrapping/PythonCore/PyVTKNamespace.cxx
@@ -49,7 +49,7 @@ PyTypeObject PyVTKNamespace_Type = {
0, // tp_basicsize
0, // tp_itemsize
PyVTKNamespace_Delete, // tp_dealloc
- nullptr, // tp_print
+ 0, // tp_vectorcall_offset
nullptr, // tp_getattr
nullptr, // tp_setattr
nullptr, // tp_compare
diff --git a/Wrapping/PythonCore/PyVTKReference.cxx b/Wrapping/PythonCore/PyVTKReference.cxx
index 943ac71080..b7104091c0 100644
--- a/Wrapping/PythonCore/PyVTKReference.cxx
+++ b/Wrapping/PythonCore/PyVTKReference.cxx
@@ -1010,7 +1010,7 @@ PyTypeObject PyVTKReference_Type = {
sizeof(PyVTKReference), // tp_basicsize
0, // tp_itemsize
PyVTKReference_Delete, // tp_dealloc
- nullptr, // tp_print
+ 0, // tp_vectorcall_offset
nullptr, // tp_getattr
nullptr, // tp_setattr
nullptr, // tp_compare
@@ -1067,7 +1067,7 @@ PyTypeObject PyVTKNumberReference_Type = {
sizeof(PyVTKReference), // tp_basicsize
0, // tp_itemsize
PyVTKReference_Delete, // tp_dealloc
- nullptr, // tp_print
+ 0, // tp_vectorcall_offset
nullptr, // tp_getattr
nullptr, // tp_setattr
nullptr, // tp_compare
@@ -1124,7 +1124,7 @@ PyTypeObject PyVTKStringReference_Type = {
sizeof(PyVTKReference), // tp_basicsize
0, // tp_itemsize
PyVTKReference_Delete, // tp_dealloc
- nullptr, // tp_print
+ 0, // tp_vectorcall_offset
nullptr, // tp_getattr
nullptr, // tp_setattr
nullptr, // tp_compare
@@ -1181,7 +1181,7 @@ PyTypeObject PyVTKTupleReference_Type = {
sizeof(PyVTKReference), // tp_basicsize
0, // tp_itemsize
PyVTKReference_Delete, // tp_dealloc
- nullptr, // tp_print
+ 0, // tp_vectorcall_offset
nullptr, // tp_getattr
nullptr, // tp_setattr
nullptr, // tp_compare
diff --git a/Wrapping/PythonCore/PyVTKTemplate.cxx b/Wrapping/PythonCore/PyVTKTemplate.cxx
index be200985b3..340fe7953b 100644
--- a/Wrapping/PythonCore/PyVTKTemplate.cxx
+++ b/Wrapping/PythonCore/PyVTKTemplate.cxx
@@ -268,7 +268,7 @@ PyTypeObject PyVTKTemplate_Type = {
0, // tp_basicsize
0, // tp_itemsize
nullptr, // tp_dealloc
- nullptr, // tp_print
+ 0, // tp_vectorcall_offset
nullptr, // tp_getattr
nullptr, // tp_setattr
nullptr, // tp_compare
diff --git a/Wrapping/PythonCore/vtkPythonCompatibility.h b/Wrapping/PythonCore/vtkPythonCompatibility.h
index 4a767844a6..be208faeef 100644
--- a/Wrapping/PythonCore/vtkPythonCompatibility.h
+++ b/Wrapping/PythonCore/vtkPythonCompatibility.h
@@ -64,7 +64,13 @@
#endif
// PyTypeObject compatibility
-#if PY_VERSION_HEX >= 0x03040000
+#if PY_VERSION_HEX >= 0x03090000
+#define VTK_WRAP_PYTHON_SUPPRESS_UNINITIALIZED \
+ 0, 0, 0, 0,
+#elif PY_VERSION_HEX >= 0x03080000
+#define VTK_WRAP_PYTHON_SUPPRESS_UNINITIALIZED \
+ 0, 0, 0, 0, 0,
+#elif PY_VERSION_HEX >= 0x03040000
#define VTK_WRAP_PYTHON_SUPPRESS_UNINITIALIZED \
0, 0, 0,
#else
diff --git a/Wrapping/Tools/vtkWrapPythonClass.c b/Wrapping/Tools/vtkWrapPythonClass.c
index b1e45f8e80..4d558ea081 100644
--- a/Wrapping/Tools/vtkWrapPythonClass.c
+++ b/Wrapping/Tools/vtkWrapPythonClass.c
@@ -521,7 +521,7 @@ void vtkWrapPython_GenerateObjectType(
" sizeof(PyVTKObject), // tp_basicsize\n"
" 0, // tp_itemsize\n"
" PyVTKObject_Delete, // tp_dealloc\n"
- " nullptr, // tp_print\n"
+ " 0, // tp_vectorcall_offset\n"
" nullptr, // tp_getattr\n"
" nullptr, // tp_setattr\n"
" nullptr, // tp_compare\n"
diff --git a/Wrapping/Tools/vtkWrapPythonEnum.c b/Wrapping/Tools/vtkWrapPythonEnum.c
index b933702242..1249362854 100644
--- a/Wrapping/Tools/vtkWrapPythonEnum.c
+++ b/Wrapping/Tools/vtkWrapPythonEnum.c
@@ -145,7 +145,7 @@ void vtkWrapPython_GenerateEnumType(
" sizeof(PyIntObject), // tp_basicsize\n"
" 0, // tp_itemsize\n"
" nullptr, // tp_dealloc\n"
- " nullptr, // tp_print\n"
+ " 0, // tp_vectorcall_offset\n"
" nullptr, // tp_getattr\n"
" nullptr, // tp_setattr\n"
" nullptr, // tp_compare\n"
diff --git a/Wrapping/Tools/vtkWrapPythonType.c b/Wrapping/Tools/vtkWrapPythonType.c
index 744cb1b9d3..0a1375e541 100644
--- a/Wrapping/Tools/vtkWrapPythonType.c
+++ b/Wrapping/Tools/vtkWrapPythonType.c
@@ -709,7 +709,7 @@ void vtkWrapPython_GenerateSpecialType(
" sizeof(PyVTKSpecialObject), // tp_basicsize\n"
" 0, // tp_itemsize\n"
" Py%s_Delete, // tp_dealloc\n"
- " nullptr, // tp_print\n"
+ " 0, // tp_vectorcall_offset\n"
" nullptr, // tp_getattr\n"
" nullptr, // tp_setattr\n"
" nullptr, // tp_compare\n"
--
2.21.0

View File

@ -17,7 +17,7 @@
Summary: The Visualization Toolkit - A high level 3D visualization library
Name: vtk
Version: 8.2.0
Release: 7%{?dist}
Release: 8%{?dist}
# This is a variant BSD license, a cross between BSD and ZLIB.
# For all intents, it has the same rights and restrictions as BSD.
# http://fedoraproject.org/wiki/Licensing/BSD#VTKBSDVariant
@ -26,8 +26,8 @@ Source0: http://www.vtk.org/files/release/8.2/VTK-%{version}.tar.gz
Source1: http://www.vtk.org/files/release/8.2/VTKData-%{version}.tar.gz
Source2: xorg.conf
Source3: FindPEGTL.cmake
# Python 3.7 compat
Patch0: https://gitlab.kitware.com/vtk/vtk/merge_requests/4490.patch
# Python 3.8 support
Patch0: https://gitlab.kitware.com/vtk/vtk/merge_requests/5883.patch
URL: http://vtk.org/
@ -538,6 +538,7 @@ programming languages.
%prep
%setup -q -b 1 -n VTK-%{version}
%patch0 -p1 -b .py38
# Remove included thirdparty sources just to be sure
# TODO - diy2 - not yet packaged
# TODO - exodusII - not yet packaged
@ -986,6 +987,9 @@ cat xorg.log
%changelog
* Tue Aug 20 2019 Orion Poplawski <orion@nwra.com> - 8.2.0-8
- Add upstream patch to support Python 3.8
* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 8.2.0-7
- Rebuilt for Python 3.8