Browse Source

Add support for Python 3.8

rdb 6 years ago
parent
commit
df8ccdb7ab

+ 10 - 1
dtool/src/interrogate/interfaceMakerPythonNative.cxx

@@ -2863,8 +2863,13 @@ write_module_class(ostream &out, Object *obj) {
 
 
   // destructor tp_dealloc;
   // destructor tp_dealloc;
   out << "    &Dtool_FreeInstance_" << ClassName << ",\n";
   out << "    &Dtool_FreeInstance_" << ClassName << ",\n";
-  // printfunc tp_print;
+
+  out << "#if PY_VERSION_HEX >= 0x03080000\n";
+  out << "    0, // tp_vectorcall_offset\n";
+  out << "#else\n";
   write_function_slot(out, 4, slots, "tp_print");
   write_function_slot(out, 4, slots, "tp_print");
+  out << "#endif\n";
+
   // getattrfunc tp_getattr;
   // getattrfunc tp_getattr;
   write_function_slot(out, 4, slots, "tp_getattr");
   write_function_slot(out, 4, slots, "tp_getattr");
   // setattrfunc tp_setattr;
   // setattrfunc tp_setattr;
@@ -3055,6 +3060,10 @@ write_module_class(ostream &out, Object *obj) {
   out << "#if PY_VERSION_HEX >= 0x03040000\n";
   out << "#if PY_VERSION_HEX >= 0x03040000\n";
   out << "    nullptr, // tp_finalize\n";
   out << "    nullptr, // tp_finalize\n";
   out << "#endif\n";
   out << "#endif\n";
+  // vectorcallfunc tp_vectorcall
+  out << "#if PY_VERSION_HEX >= 0x03080000\n";
+  out << "    nullptr, // tp_vectorcall\n";
+  out << "#endif\n";
   out << "  },\n";
   out << "  },\n";
 
 
   // It's tempting to initialize the type handle here, but this causes static
   // It's tempting to initialize the type handle here, but this causes static

+ 8 - 1
dtool/src/interrogatedb/dtool_super_base.cxx

@@ -80,7 +80,7 @@ Dtool_PyTypedObject *Dtool_GetSuperBase() {
       sizeof(Dtool_PyInstDef),
       sizeof(Dtool_PyInstDef),
       0, // tp_itemsize
       0, // tp_itemsize
       &Dtool_FreeInstance_DTOOL_SUPER_BASE,
       &Dtool_FreeInstance_DTOOL_SUPER_BASE,
-      nullptr, // tp_print
+      0, // tp_vectorcall_offset
       nullptr, // tp_getattr
       nullptr, // tp_getattr
       nullptr, // tp_setattr
       nullptr, // tp_setattr
 #if PY_MAJOR_VERSION >= 3
 #if PY_MAJOR_VERSION >= 3
@@ -129,6 +129,13 @@ Dtool_PyTypedObject *Dtool_GetSuperBase() {
       nullptr, // tp_subclasses
       nullptr, // tp_subclasses
       nullptr, // tp_weaklist
       nullptr, // tp_weaklist
       nullptr, // tp_del
       nullptr, // tp_del
+      0, // tp_version_tag,
+#if PY_VERSION_HEX >= 0x03040000
+      nullptr, // tp_finalize
+#endif
+#if PY_VERSION_HEX >= 0x03080000
+      nullptr, // tp_vectorcall
+#endif
     },
     },
     TypeHandle::none(),
     TypeHandle::none(),
     Dtool_PyModuleClassInit_DTOOL_SUPER_BASE,
     Dtool_PyModuleClassInit_DTOOL_SUPER_BASE,

+ 1 - 1
dtool/src/interrogatedb/py_compat.h

@@ -139,7 +139,7 @@ typedef long Py_hash_t;
 
 
 /* Python 3.6 */
 /* Python 3.6 */
 
 
-#ifndef _PyObject_CallNoArg
+#if PY_VERSION_HEX < 0x03080000 && !defined(_PyObject_CallNoArg)
 INLINE PyObject *_PyObject_CallNoArg(PyObject *func) {
 INLINE PyObject *_PyObject_CallNoArg(PyObject *func) {
   static PyTupleObject empty_tuple = {PyVarObject_HEAD_INIT(nullptr, 0)};
   static PyTupleObject empty_tuple = {PyVarObject_HEAD_INIT(nullptr, 0)};
 #ifdef Py_TRACE_REFS
 #ifdef Py_TRACE_REFS

+ 73 - 10
dtool/src/interrogatedb/py_wrappers.cxx

@@ -541,7 +541,7 @@ static PyObject *Dtool_MappingWrapper_keys(PyObject *self, PyObject *) {
     sizeof(Dtool_SequenceWrapper),
     sizeof(Dtool_SequenceWrapper),
     0, // tp_itemsize
     0, // tp_itemsize
     Dtool_WrapperBase_dealloc,
     Dtool_WrapperBase_dealloc,
-    nullptr, // tp_print
+    0, // tp_vectorcall_offset
     nullptr, // tp_getattr
     nullptr, // tp_getattr
     nullptr, // tp_setattr
     nullptr, // tp_setattr
     nullptr, // tp_compare
     nullptr, // tp_compare
@@ -582,6 +582,13 @@ static PyObject *Dtool_MappingWrapper_keys(PyObject *self, PyObject *) {
     nullptr, // tp_subclasses
     nullptr, // tp_subclasses
     nullptr, // tp_weaklist
     nullptr, // tp_weaklist
     nullptr, // tp_del
     nullptr, // tp_del
+    0, // tp_version_tag,
+#if PY_VERSION_HEX >= 0x03040000
+    nullptr, // tp_finalize
+#endif
+#if PY_VERSION_HEX >= 0x03080000
+    nullptr, // tp_vectorcall
+#endif
   };
   };
 
 
   static bool registered = false;
   static bool registered = false;
@@ -675,7 +682,7 @@ static PyObject *Dtool_MappingWrapper_values(PyObject *self, PyObject *) {
     sizeof(Dtool_MappingWrapper),
     sizeof(Dtool_MappingWrapper),
     0, // tp_itemsize
     0, // tp_itemsize
     Dtool_WrapperBase_dealloc,
     Dtool_WrapperBase_dealloc,
-    nullptr, // tp_print
+    0, // tp_vectorcall_offset
     nullptr, // tp_getattr
     nullptr, // tp_getattr
     nullptr, // tp_setattr
     nullptr, // tp_setattr
     nullptr, // tp_compare
     nullptr, // tp_compare
@@ -716,6 +723,13 @@ static PyObject *Dtool_MappingWrapper_values(PyObject *self, PyObject *) {
     nullptr, // tp_subclasses
     nullptr, // tp_subclasses
     nullptr, // tp_weaklist
     nullptr, // tp_weaklist
     nullptr, // tp_del
     nullptr, // tp_del
+    0, // tp_version_tag,
+#if PY_VERSION_HEX >= 0x03040000
+    nullptr, // tp_finalize
+#endif
+#if PY_VERSION_HEX >= 0x03080000
+    nullptr, // tp_vectorcall
+#endif
   };
   };
 
 
   static bool registered = false;
   static bool registered = false;
@@ -817,7 +831,7 @@ static PyObject *Dtool_MappingWrapper_items(PyObject *self, PyObject *) {
     sizeof(Dtool_MappingWrapper),
     sizeof(Dtool_MappingWrapper),
     0, // tp_itemsize
     0, // tp_itemsize
     Dtool_WrapperBase_dealloc,
     Dtool_WrapperBase_dealloc,
-    nullptr, // tp_print
+    0, // tp_vectorcall_offset
     nullptr, // tp_getattr
     nullptr, // tp_getattr
     nullptr, // tp_setattr
     nullptr, // tp_setattr
     nullptr, // tp_compare
     nullptr, // tp_compare
@@ -858,6 +872,13 @@ static PyObject *Dtool_MappingWrapper_items(PyObject *self, PyObject *) {
     nullptr, // tp_subclasses
     nullptr, // tp_subclasses
     nullptr, // tp_weaklist
     nullptr, // tp_weaklist
     nullptr, // tp_del
     nullptr, // tp_del
+    0, // tp_version_tag,
+#if PY_VERSION_HEX >= 0x03040000
+    nullptr, // tp_finalize
+#endif
+#if PY_VERSION_HEX >= 0x03080000
+    nullptr, // tp_vectorcall
+#endif
   };
   };
 
 
   static bool registered = false;
   static bool registered = false;
@@ -1192,7 +1213,7 @@ Dtool_SequenceWrapper *Dtool_NewSequenceWrapper(PyObject *self, const char *name
     sizeof(Dtool_SequenceWrapper),
     sizeof(Dtool_SequenceWrapper),
     0, // tp_itemsize
     0, // tp_itemsize
     Dtool_WrapperBase_dealloc,
     Dtool_WrapperBase_dealloc,
-    nullptr, // tp_print
+    0, // tp_vectorcall_offset
     nullptr, // tp_getattr
     nullptr, // tp_getattr
     nullptr, // tp_setattr
     nullptr, // tp_setattr
     nullptr, // tp_compare
     nullptr, // tp_compare
@@ -1233,6 +1254,13 @@ Dtool_SequenceWrapper *Dtool_NewSequenceWrapper(PyObject *self, const char *name
     nullptr, // tp_subclasses
     nullptr, // tp_subclasses
     nullptr, // tp_weaklist
     nullptr, // tp_weaklist
     nullptr, // tp_del
     nullptr, // tp_del
+    0, // tp_version_tag,
+#if PY_VERSION_HEX >= 0x03040000
+    nullptr, // tp_finalize
+#endif
+#if PY_VERSION_HEX >= 0x03080000
+    nullptr, // tp_vectorcall
+#endif
   };
   };
 
 
   static bool registered = false;
   static bool registered = false;
@@ -1296,7 +1324,7 @@ Dtool_MutableSequenceWrapper *Dtool_NewMutableSequenceWrapper(PyObject *self, co
     sizeof(Dtool_MutableSequenceWrapper),
     sizeof(Dtool_MutableSequenceWrapper),
     0, // tp_itemsize
     0, // tp_itemsize
     Dtool_WrapperBase_dealloc,
     Dtool_WrapperBase_dealloc,
-    nullptr, // tp_print
+    0, // tp_vectorcall_offset
     nullptr, // tp_getattr
     nullptr, // tp_getattr
     nullptr, // tp_setattr
     nullptr, // tp_setattr
     nullptr, // tp_compare
     nullptr, // tp_compare
@@ -1337,6 +1365,13 @@ Dtool_MutableSequenceWrapper *Dtool_NewMutableSequenceWrapper(PyObject *self, co
     nullptr, // tp_subclasses
     nullptr, // tp_subclasses
     nullptr, // tp_weaklist
     nullptr, // tp_weaklist
     nullptr, // tp_del
     nullptr, // tp_del
+    0, // tp_version_tag,
+#if PY_VERSION_HEX >= 0x03040000
+    nullptr, // tp_finalize
+#endif
+#if PY_VERSION_HEX >= 0x03080000
+    nullptr, // tp_vectorcall
+#endif
   };
   };
 
 
   static bool registered = false;
   static bool registered = false;
@@ -1404,7 +1439,7 @@ Dtool_MappingWrapper *Dtool_NewMappingWrapper(PyObject *self, const char *name)
     sizeof(Dtool_MappingWrapper),
     sizeof(Dtool_MappingWrapper),
     0, // tp_itemsize
     0, // tp_itemsize
     Dtool_WrapperBase_dealloc,
     Dtool_WrapperBase_dealloc,
-    nullptr, // tp_print
+    0, // tp_vectorcall_offset
     nullptr, // tp_getattr
     nullptr, // tp_getattr
     nullptr, // tp_setattr
     nullptr, // tp_setattr
     nullptr, // tp_compare
     nullptr, // tp_compare
@@ -1445,6 +1480,13 @@ Dtool_MappingWrapper *Dtool_NewMappingWrapper(PyObject *self, const char *name)
     nullptr, // tp_subclasses
     nullptr, // tp_subclasses
     nullptr, // tp_weaklist
     nullptr, // tp_weaklist
     nullptr, // tp_del
     nullptr, // tp_del
+    0, // tp_version_tag,
+#if PY_VERSION_HEX >= 0x03040000
+    nullptr, // tp_finalize
+#endif
+#if PY_VERSION_HEX >= 0x03080000
+    nullptr, // tp_vectorcall
+#endif
   };
   };
 
 
   static bool registered = false;
   static bool registered = false;
@@ -1517,7 +1559,7 @@ Dtool_MappingWrapper *Dtool_NewMutableMappingWrapper(PyObject *self, const char
     sizeof(Dtool_MappingWrapper),
     sizeof(Dtool_MappingWrapper),
     0, // tp_itemsize
     0, // tp_itemsize
     Dtool_WrapperBase_dealloc,
     Dtool_WrapperBase_dealloc,
-    nullptr, // tp_print
+    0, // tp_vectorcall_offset
     nullptr, // tp_getattr
     nullptr, // tp_getattr
     nullptr, // tp_setattr
     nullptr, // tp_setattr
     nullptr, // tp_compare
     nullptr, // tp_compare
@@ -1558,6 +1600,13 @@ Dtool_MappingWrapper *Dtool_NewMutableMappingWrapper(PyObject *self, const char
     nullptr, // tp_subclasses
     nullptr, // tp_subclasses
     nullptr, // tp_weaklist
     nullptr, // tp_weaklist
     nullptr, // tp_del
     nullptr, // tp_del
+    0, // tp_version_tag,
+#if PY_VERSION_HEX >= 0x03040000
+    nullptr, // tp_finalize
+#endif
+#if PY_VERSION_HEX >= 0x03080000
+    nullptr, // tp_vectorcall
+#endif
   };
   };
 
 
   static bool registered = false;
   static bool registered = false;
@@ -1594,7 +1643,7 @@ Dtool_NewGenerator(PyObject *self, iternextfunc gen_next) {
     sizeof(Dtool_GeneratorWrapper),
     sizeof(Dtool_GeneratorWrapper),
     0, // tp_itemsize
     0, // tp_itemsize
     Dtool_WrapperBase_dealloc,
     Dtool_WrapperBase_dealloc,
-    nullptr, // tp_print
+    0, // tp_vectorcall_offset
     nullptr, // tp_getattr
     nullptr, // tp_getattr
     nullptr, // tp_setattr
     nullptr, // tp_setattr
     nullptr, // tp_compare
     nullptr, // tp_compare
@@ -1635,6 +1684,13 @@ Dtool_NewGenerator(PyObject *self, iternextfunc gen_next) {
     nullptr, // tp_subclasses
     nullptr, // tp_subclasses
     nullptr, // tp_weaklist
     nullptr, // tp_weaklist
     nullptr, // tp_del
     nullptr, // tp_del
+    0, // tp_version_tag,
+#if PY_VERSION_HEX >= 0x03040000
+    nullptr, // tp_finalize
+#endif
+#if PY_VERSION_HEX >= 0x03080000
+    nullptr, // tp_vectorcall
+#endif
   };
   };
 
 
   if (PyType_Ready(&wrapper_type) < 0) {
   if (PyType_Ready(&wrapper_type) < 0) {
@@ -1663,7 +1719,7 @@ Dtool_NewStaticProperty(PyTypeObject *type, const PyGetSetDef *getset) {
     sizeof(PyGetSetDescrObject),
     sizeof(PyGetSetDescrObject),
     0, // tp_itemsize
     0, // tp_itemsize
     (destructor)Dtool_StaticProperty_dealloc,
     (destructor)Dtool_StaticProperty_dealloc,
-    nullptr, // tp_print
+    0, // tp_vectorcall_offset
     nullptr, // tp_getattr
     nullptr, // tp_getattr
     nullptr, // tp_setattr
     nullptr, // tp_setattr
     nullptr, // tp_reserved
     nullptr, // tp_reserved
@@ -1696,7 +1752,7 @@ Dtool_NewStaticProperty(PyTypeObject *type, const PyGetSetDef *getset) {
     nullptr, // tp_init
     nullptr, // tp_init
     nullptr, // tp_alloc
     nullptr, // tp_alloc
     nullptr, // tp_new
     nullptr, // tp_new
-    nullptr, // tp_del
+    nullptr, // tp_free
     nullptr, // tp_is_gc
     nullptr, // tp_is_gc
     nullptr, // tp_bases
     nullptr, // tp_bases
     nullptr, // tp_mro
     nullptr, // tp_mro
@@ -1704,6 +1760,13 @@ Dtool_NewStaticProperty(PyTypeObject *type, const PyGetSetDef *getset) {
     nullptr, // tp_subclasses
     nullptr, // tp_subclasses
     nullptr, // tp_weaklist
     nullptr, // tp_weaklist
     nullptr, // tp_del
     nullptr, // tp_del
+    0, // tp_version_tag,
+#if PY_VERSION_HEX >= 0x03040000
+    nullptr, // tp_finalize
+#endif
+#if PY_VERSION_HEX >= 0x03080000
+    nullptr, // tp_vectorcall
+#endif
   };
   };
 
 
   if (PyType_Ready(&wrapper_type) < 0) {
   if (PyType_Ready(&wrapper_type) < 0) {

+ 3 - 1
makepanda/makepanda.py

@@ -2918,7 +2918,9 @@ if '__file__' in locals():
 
 
     bindir = os.path.join(os.path.dirname(__file__), '..', 'bin')
     bindir = os.path.join(os.path.dirname(__file__), '..', 'bin')
     if os.path.isdir(bindir):
     if os.path.isdir(bindir):
-        if not os.environ.get('PATH'):
+        if hasattr(os, 'add_dll_directory'):
+            os.add_dll_directory(bindir)
+        elif not os.environ.get('PATH'):
             os.environ['PATH'] = bindir
             os.environ['PATH'] = bindir
         else:
         else:
             os.environ['PATH'] = bindir + os.pathsep + os.environ['PATH']
             os.environ['PATH'] = bindir + os.pathsep + os.environ['PATH']

+ 5 - 2
makepanda/makewheel.py

@@ -168,15 +168,18 @@ questions.
 PANDA3D_TOOLS_INIT = """import os, sys
 PANDA3D_TOOLS_INIT = """import os, sys
 import panda3d
 import panda3d
 
 
+dir = os.path.dirname(panda3d.__file__)
+del panda3d
+
 if sys.platform in ('win32', 'cygwin'):
 if sys.platform in ('win32', 'cygwin'):
     path_var = 'PATH'
     path_var = 'PATH'
+    if hasattr(os, 'add_dll_directory'):
+        os.add_dll_directory(dir)
 elif sys.platform == 'darwin':
 elif sys.platform == 'darwin':
     path_var = 'DYLD_LIBRARY_PATH'
     path_var = 'DYLD_LIBRARY_PATH'
 else:
 else:
     path_var = 'LD_LIBRARY_PATH'
     path_var = 'LD_LIBRARY_PATH'
 
 
-dir = os.path.dirname(panda3d.__file__)
-del panda3d
 if not os.environ.get(path_var):
 if not os.environ.get(path_var):
     os.environ[path_var] = dir
     os.environ[path_var] = dir
 else:
 else: