CPython embedding/extending backend with support for multiple Python versions.
RtLoader is a C++ wrapper around the CPython API with a C89-compatible public API
that can be used by foreign languages like Go. In order to provide support for
multiple Python versions, RtLoader fully abstracts Python in order to decouple client
applications and CPython. Which Python version to use can be decided at runtime,
RtLoader will dlopen the proper backend libraries accordingly.
RtLoader exposes its C89-compatible API through include/datadog_agent_rtloader.h. By
using the make3 function, the corresponding Python backend will
be loaded at runtime. Under the hood the library provides RtLoader, a C++ interface
that must be implemented by any supported backend, see include/rtloader.h for details.
libdatadog-agent-three library provides Python3 support. Python2 isn't supported anymore.
The common folder contains C/C++ modules that are compiled into libdatadog-agent-three.
Most of the code used to extend the embedded interpreter is there.
- C/C++ compiler
- Python 3.12.x development packages
- Cmake version 3.15 or above
- Go compiler with
cgocapabilities to run the tests
RTLoader can optionally show stack traces when a segfault happens, using execinfo, which is provided out of the box by the glibc.
When building with other libc, you can install the shared libraries libexecinfo or libbacktrace instead.
CMake should automatically pick it up so that you don't need to configure anything.
If it doesn't, you can explicitly tell it where to find those by setting Backtrace_LIBRARY and Backtrace_INCLUDE_DIR options, eg. -DBacktrace_LIBRARY=/usr/lib/libexecinfo.so -DBacktrace_INCLUDE_DIR=/usr/include.
RtLoader can be built using CMake. Run the configurator/generator first:
cmake .Then just run make to build the project.
Tests are written in Golang using cgo, run the testsuite from the root folder:
make -C test