| 38 | constexpr const char* PYTORCH_INDEX = "https://download.pytorch.org/whl/"; |
| 39 | |
| 40 | std::filesystem::path get_executable_dir() { |
| 41 | #ifdef _WIN32 |
| 42 | wchar_t path[MAX_PATH_LEN]; |
| 43 | GetModuleFileNameW(nullptr, path, MAX_PATH_LEN); |
| 44 | return std::filesystem::path(path).parent_path(); |
| 45 | #else |
| 46 | char path[MAX_PATH_LEN]; |
| 47 | const ssize_t len = readlink("/proc/self/exe", path, sizeof(path) - 1); |
| 48 | if (len != -1) { |
| 49 | path[len] = '\0'; |
| 50 | return std::filesystem::path(path).parent_path(); |
| 51 | } |
| 52 | return std::filesystem::current_path(); |
| 53 | #endif |
| 54 | } |
| 55 | |
| 56 | std::pair<int, std::string> execute_process_capture( |
| 57 | const std::filesystem::path& program, |