Build single Python.Runtime.dll for all platforms by lostmsu · Pull Request #1365 · pythonnet/pythonnet
What does this implement/fix? Explain your changes.
This allows building the same Python.Runtime.dll on all platforms and supported Python versions.
To invoke Python code from .NET, one needs to set Python.Runtime.Runtime.PythonDLL or manually preload DLL before invoking any Python.NET functions or other properties.
Implementation details
PInvoke signatures have been replaced with unmanaged functions pointers, that are loaded using ILibraryLoader on the first attempt to call any Python C API functions.
Marshaling attributes have been replaced with explicit marshaling calls.
PythonDLL gets its default value in the following order from:
PYTHONNET_PYDLLenvironment variable- Is set to
nullwhen launched from Python (so that DLL is already loaded in the process). - Set to a platform-dependent value, based on
PYTHONNET_PYVERenvironment variable (e.g. '3.6' -> 'libpython3.6.so')
Checklist
Check all those that are applicable and complete.