LLDB mainline
PythonPathSetup.h File Reference
#include "llvm/Support/Error.h"

Go to the source code of this file.

Functions

llvm::Expected< std::string > SetupPythonRuntimeLibrary ()
 Attempts to setup the DLL search path for the Python runtime library.

Function Documentation

◆ SetupPythonRuntimeLibrary()

llvm::Expected< std::string > SetupPythonRuntimeLibrary ( )

Attempts to setup the DLL search path for the Python runtime library.

In the following paragraphs, python3xx.dll refers to the Python runtime library name which is defined by LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME, e.g. python311.dll for Python 3.11.

The setup flow depends on which macros are defined:

  • If only LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME is defined, checks whether python3xx.dll can be loaded. Returns an error if it cannot.
  • If only LLDB_PYTHON_DLL_RELATIVE_PATH is defined, attempts to resolve the relative path and add it to the DLL search path. Returns an error if this fails. Note that this may succeed even if python3xx.dll is not present in the added search path.
  • If both LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME and LLDB_PYTHON_DLL_RELATIVE_PATH are defined, first checks if python3xx.dll can be loaded. If successful, returns immediately. Otherwise, attempts to resolve the relative path and add it to the DLL search path, then checks again if python3xx.dll can be loaded.
Returns
If LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME is defined, return the absolute path of the Python shared library which was resolved or an error if it could not be found. If LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME and LLDB_PYTHON_DLL_RELATIVE_PATH are not defined, return an empty string.

Definition at line 81 of file PythonPathSetup.cpp.

References createStringError().