MCPcopy Create free account
hub / github.com/MrNeRF/LichtFeld-Studio / update_python_path

Function update_python_path

src/python/runner.cpp:1008–1025  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1006 }
1007
1008 void update_python_path() {
1009 const auto packages = get_user_packages_dir();
1010 if (!std::filesystem::exists(packages))
1011 return;
1012
1013 const GilAcquire gil;
1014
1015 PyObject* const sys_path = PySys_GetObject("path");
1016 if (sys_path) {
1017 const auto path_str = lfs::core::path_to_utf8(packages);
1018 PyObject* const py_path = PyUnicode_FromString(path_str.c_str());
1019 if (PySequence_Contains(sys_path, py_path) == 0) {
1020 PyList_Insert(sys_path, 0, py_path);
1021 LOG_INFO("Added to sys.path: {}", path_str);
1022 }
1023 Py_DECREF(py_path);
1024 }
1025 }
1026
1027 std::expected<void, std::string> run_scripts(const std::vector<std::filesystem::path>& scripts) {
1028 if (scripts.empty()) {

Callers 4

start_debugpyFunction · 0.85
start_embedded_replFunction · 0.85
format_python_code_implFunction · 0.85
register_packagesFunction · 0.85

Calls 3

get_user_packages_dirFunction · 0.85
path_to_utf8Function · 0.85
c_strMethod · 0.80

Tested by

no test coverage detected