File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020
2121#include < bit>
2222#include < filesystem>
23+ #include < format>
2324
2425using namespace py ;
2526
2627static PyModule *s_sys_module = nullptr ;
2728
29+ #if defined(__clang__)
30+ #define COMPILER_VERSION " [Clang " __clang_version__ " ]"
31+ #elif defined(__GNUC__)
32+ #define COMPILER_VERSION " [GCC " __VERSION__ " ]"
33+ #else
34+ static_assert (false , " Unknown compiler!" );
35+ #endif
36+
2837namespace {
2938PyResult<PyList *> create_sys_paths (Interpreter &interpreter)
3039{
@@ -414,6 +423,20 @@ PyModule *sys_module(Interpreter &interpreter)
414423
415424 s_sys_module->add_symbol (PyString::create (" warnoptions" ).unwrap (), PyList::create ().unwrap ());
416425
426+ s_sys_module->add_symbol (PyString::create (" executable" ).unwrap (),
427+ PyString::create (std::filesystem::canonical (" /proc/self/exe" ).string ()).unwrap ());
428+
429+ s_sys_module->add_symbol (PyString::create (" base_prefix" ).unwrap (),
430+ PyString::create (std::string{ kPythonInstallPath }).unwrap ());
431+
432+ s_sys_module->add_symbol (PyString::create (" executable" ).unwrap (),
433+ PyString::create (std::filesystem::canonical (" /proc/self/exe" ).string ()).unwrap ());
434+
435+ std::string py_version = std::format (" 3.9.0 (main) {}" , COMPILER_VERSION);
436+
437+ s_sys_module->add_symbol (
438+ PyString::create (" version" ).unwrap (), PyString::create (py_version).unwrap ());
439+
417440 return s_sys_module;
418441}
419442
You can’t perform that action at this time.
0 commit comments