File vbox-python-selection.patch of Package virtualbox

Index: VirtualBox-7.0.14/src/bldprogs/scm.cpp
===================================================================
--- VirtualBox-7.0.14.orig/src/bldprogs/scm.cpp
+++ VirtualBox-7.0.14/src/bldprogs/scm.cpp
@@ -2367,7 +2367,7 @@ static int scmProcessFileInner(PSCMRWSTA
                             pszTreatAs = "shell";
                         else if (   (cchFirst >= 15 && strncmp(pchFirst, "/usr/bin/python", 15) == 0)
                                  || (cchFirst >= 19 && strncmp(pchFirst, "/usr/bin/env python", 19) == 0) )
-                            pszTreatAs = "python";
+                            pszTreatAs = "python3";
                         else if (   (cchFirst >= 13 && strncmp(pchFirst, "/usr/bin/perl", 13) == 0)
                                  || (cchFirst >= 17 && strncmp(pchFirst, "/usr/bin/env perl", 17) == 0) )
                             pszTreatAs = "perl";
Index: VirtualBox-7.0.14/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
===================================================================
--- VirtualBox-7.0.14.orig/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
+++ VirtualBox-7.0.14/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
@@ -32,6 +32,9 @@
 %define VBOXDOCDIR %{_defaultdocdir}/%NAME%
 %global __requires_exclude_from ^/usr/lib/virtualbox/VBoxPython.*$|^/usr/lib/python.*$|^.*\\.py$
 %{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
+# SUSE defines these in python-rpm-macros, not necessarily available here
+%{!?__python3:%{_bindir}/python3}}
+%{!?python3_sitelib: %define python_sitelib python3 -c "import sysconfig as s; print(s.get_paths().get('purelib'))"}
 
 Summary:   Oracle VM VirtualBox
 Name:      %NAME%
Index: VirtualBox-7.0.14/src/libs/xpcom18a4/python/src/ErrorUtils.cpp
===================================================================
--- VirtualBox-7.0.14.orig/src/libs/xpcom18a4/python/src/ErrorUtils.cpp
+++ VirtualBox-7.0.14/src/libs/xpcom18a4/python/src/ErrorUtils.cpp
@@ -438,7 +438,9 @@ char *PyTraceback_AsString(PyObject *exc
 
 	{ // a temp scope so I can use temp locals.
 #if PY_MAJOR_VERSION <= 2
-	char *tempResult = PyString_AsString(obResult);
+	char *tempResult = (char *)PyString_AsString(obResult);
+#elif PY_MINOR_VERSION <= 6
+	char *tempResult = (char *)PyUnicode_AsUTF8(obResult);
 #else
     /* PyUnicode_AsUTF8() is const char * as of Python 3.7, char * earlier. */
 	const char *tempResult = (const char *)PyUnicode_AsUTF8(obResult);
Index: VirtualBox-7.0.14/src/libs/xpcom18a4/python/src/PyGBase.cpp
===================================================================
--- VirtualBox-7.0.14.orig/src/libs/xpcom18a4/python/src/PyGBase.cpp
+++ VirtualBox-7.0.14/src/libs/xpcom18a4/python/src/PyGBase.cpp
@@ -183,7 +183,11 @@ PyG_Base::~PyG_Base()
 // Get the correct interface pointer for this object given the IID.
 void *PyG_Base::ThisAsIID( const nsIID &iid )
 {
-	if (this==NULL) return NULL;
+#if PY_MINOR_VERSION <= 6
+	if (!this) return NULL;
+#else
+	if (!this) return NULL;
+#endif
 	if (iid.Equals(NS_GET_IID(nsISupports)))
 		return (nsISupports *)(nsIInternalPython *)this;
 	if (iid.Equals(NS_GET_IID(nsISupportsWeakReference)))
Index: VirtualBox-7.0.14/src/libs/xpcom18a4/python/gen_python_deps.py
===================================================================
--- VirtualBox-7.0.14.orig/src/libs/xpcom18a4/python/gen_python_deps.py
+++ VirtualBox-7.0.14/src/libs/xpcom18a4/python/gen_python_deps.py
@@ -96,7 +96,7 @@ def main(argv):
     else:
         multi = 1
 
-    if multi == 0:
+    if not multi:
         prefixes = ["/usr"]
         versions = [str(sys.version_info[0])+'.'+str(sys.version_info[1]),
                     str(sys.version_info[0])+'.'+str(sys.version_info[1])+'m']
@@ -124,24 +124,25 @@ def main(argv):
             continue
         for p in prefixes:
             c = checkPair(p, v, dllpre, dllsuff, bitness_magic)
-            if c is not None:
+            if c:
                 known[v] = c
                 break
-    keys = list(known.keys())
-    # we want default to be the lowest versioned Python
-    keys.sort()
-    d = None
     # We need separator other than newline, to sneak through $(shell)
     sep = "|"
-    for k in keys:
-        if d is None:
-            d = k
-        vers = k.replace('.', '').upper()
-        print_vars(vers, known[k], sep, bitness_magic)
-    if d is not None:
-        print_vars("DEF", known[d], sep, bitness_magic)
+
+    if not known:
+        # this type of problem should be detected in configure
+        # print_vars("DEF", defaultpaths, sep, bitness_magic)
+        pass
     else:
         print(argv[0] + ": No Python development package found!", file=sys.stderr)
+    if multi:
+        for ver, paths in known.items():
+            print_vars(ver.replace('.', '').upper(), paths, sep, bitness_magic)
+    else:
+        ver = versions[0]
+        paths = known[ver]
+        print_vars(ver.replace('.', ''), paths, sep, bitness_magic)
 
 if __name__ == '__main__':
     main(sys.argv)
openSUSE Build Service is sponsored by