elsa-workflows / elsa-workflows/elsa-core
Build fails with Python 3.13: need to update pythonnet
- Dominant language
- C#
- Stars
- 7.9k
- Forks
- 1.5k
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 114
Description
## Description
I am trying to build Elsa on Archlinux with Python 3.13 and it fails with the following message:
```
Failed to initialize Python engine
System.TypeInitializationException: The type initializer for 'Delegates' threw an exception.
---> System.MissingMethodException: Failed to load symbol _PyThreadState_UncheckedGet: /usr/lib/libpython3.13.so: undefined symbol: _PyThreadState_UncheckedGet
at Python.Runtime.Platform.PosixLoader.GetFunction(IntPtr dllHandle, String name)
at Python.Runtime.Runtime.Delegates.GetFunctionByName(String functionName, IntPtr libraryHandle)
at Python.Runtime.Runtime.Delegates..cctor()
--- End of inner exception stack trace ---
at Python.Runtime.Runtime.Delegates.get_Py_IsInitialized()
at Python.Runtime.Runtime.Py_IsInitialized()
at Python.Runtime.Runtime.<>c.b__32_0()
at Python.Runtime.Runtime.TryUsingDll[T](Func`1 op)
at Python.Runtime.Runtime.Initialize(Boolean initSigs)
at Python.Runtime.PythonEngine.Initialize(IEnumerable`1 args, Boolean setSysArgv, Boolean initSigs)
at Python.Runtime.PythonEngine.Initialize(Boolean setSysArgv, Boolean initSigs)
at Python.Runtime.PythonEngine.Initialize()
at Elsa.Expressions.Python.HostedServices.PythonGlobalInterpreterManager.StartAsync(CancellationToken cancellationToken) in /home/pierre/programming/elsa/elsa-core/src/modules/Elsa.Expressions.Python/HostedServices/PythonGlobalInterpreterManager.cs:line 40
```
## Troubleshooting Attempts
The function `PyThreadState_UncheckedGet` indeed disappeared in Python 3.13 (cf https://docs.python.org/3/whatsnew/3.13.html and https://docs.python.org/3/c-api/init.html#c.PyThreadState_GetUnchecked).
Pythonnet became compatible with Python 3.13 last December with their [3.0.5 version](https://github.com/pythonnet/pythonnet/releases/tag/v3.0.5)
Changing pythonnet version to `3.0.5` in `Directory.Packages.props` allowed the application to compile, but I don't know if there was a specific reason to choose `3.1.0-preview2024-09-06`.
Contributor guide
Assessment
This issue has not been assessed yet.