Bug 2264230

Summary: renderdoc fails to build with Python 3.13: error: ‘_PyNone_Type’ was not declared in this scope; did you mean ‘PyLong_Type’
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: renderdocAssignee: kb1000 <fedora>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: fedora, ksurma, mhroncok
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-03-29 17:33:09 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2244836    

Description Karolina Surma 2024-02-14 17:15:57 UTC
renderdoc fails to build with Python 3.13.0a3.

/builddir/build/BUILD/renderdoc-1.31/redhat-linux-build/qrenderdoc/renderdoc_python.cxx: In function ‘PyObject* RENDERDOC_DumpObject(PyObject*)’:
/builddir/build/BUILD/renderdoc-1.31/redhat-linux-build/qrenderdoc/renderdoc_python.cxx:284466:43: error: ‘_PyNone_Type’ was not declared in this scope; did you mean ‘PyLong_Type’?
284466 |      PyObject_IsInstance(obj, (PyObject*)&_PyNone_Type) ||
       |                                           ^~~~~~~~~~~~
       |                                           PyLong_Type
renderdoc_python.cxx: In function ‘PyObject* RENDERDOC_DumpObject(PyObject*)’:
renderdoc_python.cxx:284466:43: error: ‘_PyNone_Type’ was not declared in this scope; did you mean ‘PyLong_Type’?
284466 |      PyObject_IsInstance(obj, (PyObject*)&_PyNone_Type) ||
       |                                           ^~~~~~~~~~~~
       |                                           PyLong_Type

https://docs.python.org/3.13/whatsnew/3.13.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.13/fedora-rawhide-x86_64/07015467-renderdoc/

For all our attempts to build renderdoc with Python 3.13, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/package/renderdoc/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.13:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/

Let us know here if you have any questions.

Python 3.13 is planned to be included in Fedora 41.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.13.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Miro Hrončok 2024-02-15 08:11:41 UTC
https://docs.python.org/3.13/c-api/none.html says:

Note that the PyTypeObject for None is not directly exposed in the Python/C API. Since None is a singleton, testing for object identity (using == in C) is sufficient. 

Hence this check:

    PyObject_IsInstance(obj, (PyObject*)&_PyNone_Type)

Should probably be replaced with:

    obj == Py_None

Comment 2 kb1000 2024-02-16 23:22:38 UTC
I'm looking into this, and after patching that I can see some additional errors:

compiling ../../qrenderdoc/Code/pyrenderdoc/PythonContext.cpp
../../qrenderdoc/Code/pyrenderdoc/PythonContext.cpp: In static member function ‘static void PythonContext::GlobalInit()’:
../../qrenderdoc/Code/pyrenderdoc/PythonContext.cpp:274:3: error: ‘Py_SetProgramName’ was not declared in this scope; did you mean ‘Py_GetProgramName’?
  274 |   Py_SetProgramName(program_name);
      |   ^~~~~~~~~~~~~~~~~
      |   Py_GetProgramName
../../qrenderdoc/Code/pyrenderdoc/PythonContext.cpp:280:3: error: ‘PyEval_InitThreads’ was not declared in this scope; did you mean ‘PyEval_SaveThread’?
  280 |   PyEval_InitThreads();
      |   ^~~~~~~~~~~~~~~~~~
      |   PyEval_SaveThread

This would require switching from Py_Initialize to Py_InitializeFromConfig, which was introduced in Python 3.8 while upstream still supports and uses Python 3.6.
I'm not sure yet if that's all issues, but I think so.

Comment 3 kb1000 2024-03-29 17:33:09 UTC
Seeing https://copr.fedorainfracloud.org/coprs/g/python/python3.13/build/7232827/, this is fixed now.