| 364 | } |
| 365 | |
| 366 | std::filesystem::path PackageManager::site_packages_dir() const { |
| 367 | #ifdef _WIN32 |
| 368 | return m_venv_dir / "Lib" / "site-packages"; |
| 369 | #else |
| 370 | const auto lib_dir = m_venv_dir / "lib"; |
| 371 | if (std::filesystem::exists(lib_dir)) { |
| 372 | std::filesystem::path best_match; |
| 373 | for (const auto& entry : std::filesystem::directory_iterator(lib_dir)) { |
| 374 | if (entry.is_directory()) { |
| 375 | const auto name = entry.path().filename().string(); |
| 376 | // Prefer pythonX.Y over pythonX (more specific version) |
| 377 | if (name.find("python") == 0) { |
| 378 | if (best_match.empty() || name.length() > best_match.filename().string().length()) { |
| 379 | best_match = entry.path(); |
| 380 | } |
| 381 | } |
| 382 | } |
| 383 | } |
| 384 | if (!best_match.empty()) |
| 385 | return best_match / "site-packages"; |
| 386 | } |
| 387 | return m_venv_dir / "lib" / "python3" / "site-packages"; |
| 388 | #endif |
| 389 | } |
| 390 | |
| 391 | InstallResult PackageManager::execute_uv(const std::vector<std::string>& args) const { |
| 392 | const auto uv = uv_path(); |