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

Function getPythonHome

src/core/include/core/executable_path.hpp:266–295  ·  view source on GitHub ↗

Python home directory (for embedded Python)

Source from the content-addressed store, hash-verified

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() {

Callers 2

ensure_initializedFunction · 0.85
ensure_venvMethod · 0.85

Calls 3

getExecutableDirFunction · 0.85
findVcpkgPrefixFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected