| 264 | } |
| 265 | |
| 266 | void prependPythonPath(const std::filesystem::path& path) { |
| 267 | const auto value = path.string(); |
| 268 | const char* existing = std::getenv("PYTHONPATH"); |
| 269 | #ifdef _WIN32 |
| 270 | const char separator = ';'; |
| 271 | #else |
| 272 | const char separator = ':'; |
| 273 | #endif |
| 274 | const std::string combined = |
| 275 | existing && *existing ? value + separator + std::string(existing) : value; |
| 276 | |
| 277 | #ifdef _WIN32 |
| 278 | _putenv_s("PYTHONPATH", combined.c_str()); |
| 279 | #else |
| 280 | setenv("PYTHONPATH", combined.c_str(), 1); |
| 281 | #endif |
| 282 | } |
| 283 | |
| 284 | std::string consumePythonError() { |
| 285 | if (!PyErr_Occurred()) { |