Python home directory (for embedded Python)
| 264 | |
| 265 | // Python home directory (for embedded Python) |
| 266 | inline std::filesystem::path getPythonHome() { |
| 267 | const auto exe_dir = getExecutableDir(); |
| 268 | |
| 269 | #ifdef _WIN32 |
| 270 | // Windows Production: exe in bin/, Python stdlib in ../Lib/ |
| 271 | // CPython on Windows expects Lib/ (not lib/python3.12/) |
| 272 | if (const auto prod = exe_dir.parent_path() / "Lib"; |
| 273 | std::filesystem::exists(prod / "os.py")) { |
| 274 | return exe_dir.parent_path(); |
| 275 | } |
| 276 | |
| 277 | // Windows Development (vcpkg) |
| 278 | if (const auto prefix = findVcpkgPrefix(exe_dir); !prefix.empty()) { |
| 279 | return prefix / "tools" / "python3"; |
| 280 | } |
| 281 | #else |
| 282 | // Linux Production: exe in bin/, Python stdlib in ../lib/python3.12/ |
| 283 | if (const auto prod = exe_dir.parent_path() / "lib" / "python3.12"; |
| 284 | std::filesystem::exists(prod)) { |
| 285 | return exe_dir.parent_path(); |
| 286 | } |
| 287 | |
| 288 | // Linux Development (vcpkg) |
| 289 | if (const auto prefix = findVcpkgPrefix(exe_dir); !prefix.empty()) { |
| 290 | return prefix; |
| 291 | } |
| 292 | #endif |
| 293 | |
| 294 | return {}; |
| 295 | } |
| 296 | |
| 297 | // Type stubs directory (lichtfeld/*.pyi) |
| 298 | inline std::filesystem::path getTypingsDir() { |
no test coverage detected