realthunder / FreeCAD

Link branch FreeCAD
Other
763 stars 45 forks source link

[Backport] Make RT build with Python 3.12.1 for Fedora 39... #959

Closed linuxguy123 closed 5 months ago

linuxguy123 commented 6 months ago

Original PR

https://github.com/FreeCAD/FreeCAD/pull/12286

Description and Justification

FreeCAD 0.21.1 won't build on Fedora 39 because it is based on Python 3.11 and FC39 ships with 3.12.1 and can't easily be reverted to 3.11.

This thread explains the issue and the solution. https://forum.freecad.org/viewtopic.php?t=83356&start=10

I think this is the patch that fixes things.

--- a/src/CXX/IndirectPythonInterface.cxx
+++ b/src/CXX/IndirectPythonInterface.cxx
@@ -523,7 +523,9 @@ PYCXX_EXPORT int &_Py_InteractiveFlag()              { return Py_InteractiveFlag
 PYCXX_EXPORT int &_Py_OptimizeFlag()                 { return Py_OptimizeFlag; }
 PYCXX_EXPORT int &_Py_NoSiteFlag()                   { return Py_NoSiteFlag; }
 PYCXX_EXPORT int &_Py_VerboseFlag()                  { return Py_VerboseFlag; }
-#  if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
+#  if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 12
+PYCXX_EXPORT const char *__Py_PackageContext()       { return NULL; }
+#  elif PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
 PYCXX_EXPORT const char *__Py_PackageContext()       { return _Py_PackageContext; }
 #  else
 PYCXX_EXPORT char *__Py_PackageContext()             { return _Py_PackageContext; }

Thanks for your fantastic work.