| 37 | |
| 38 | #ifdef _WIN32 |
| 39 | void setPythonHome() |
| 40 | { |
| 41 | string pythonhome = "PYTHONHOME="; |
| 42 | const char* old_pythonhome = getenv("PYTHONHOME"); |
| 43 | if (old_pythonhome != nullptr && old_pythonhome[0] != '\0') { |
| 44 | // Use existing setting of PYTHONHOME |
| 45 | return; |
| 46 | } |
| 47 | |
| 48 | const char* conda_prefix = getenv("CONDA_PREFIX"); |
| 49 | if (conda_prefix != nullptr && std::filesystem::exists(conda_prefix)) { |
| 50 | pythonhome += conda_prefix; |
| 51 | _putenv(pythonhome.c_str()); |
| 52 | return; |
| 53 | } |
| 54 | |
| 55 | #ifdef CT_PYTHONHOME |
| 56 | string build_pythonhome = stripnonprint(string(CT_PYTHONHOME)); |
| 57 | if (std::filesystem::exists(build_pythonhome)) { |
| 58 | pythonhome += build_pythonhome; |
| 59 | _putenv(pythonhome.c_str()); |
| 60 | } |
| 61 | #endif |
| 62 | } |
| 63 | #endif |
| 64 | |
| 65 | } |
no test coverage detected