| 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()) { |
no test coverage detected