.. _program_listing_file_interfaces_python.h: Program Listing for File python.h ================================= |exhale_lsh| :ref:`Return to documentation for file ` (``interfaces/python.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once #ifdef LUPNT_WITH_PYTHON # include # include # include # include namespace py = pybind11; namespace lupnt { class PythonInterpreter { public: static PythonInterpreter& GetInstance() { static PythonInterpreter instance; return instance; } private: std::optional python_; // Manages Python interpreter PythonInterpreter() { // Only initialize if we're not already in a Python process if (!Py_IsInitialized()) { python_.emplace(); } } ~PythonInterpreter() = default; PythonInterpreter(const PythonInterpreter&) = delete; PythonInterpreter& operator=(const PythonInterpreter&) = delete; }; extern py::module_ py_pnt; extern py::module_ py_pio; extern py::module_ py_go; extern py::module_ py_plot; extern py::module_ py_plt; } // namespace lupnt #endif // LUPNT_WITH_PYTHON