// Planu — Python package manager detector (uv, poetry, hatch, rye, pip)
import { join } from 'node:path';
import { hasAnyFile, readTextFile } from '../detection-utils.js';
/**
 * SPEC-004 tech-debt: Detect Python package manager (uv, poetry, pip, hatch, rye).
 * uv is the fastest Python PM (2024-2025), detected via uv.lock or [tool.uv] in pyproject.toml.
 */
export async function detectPythonPackageManager(projectPath) {
    // uv: fastest Python PM — uv.lock file is definitive
    if (await hasAnyFile(projectPath, ['uv.lock'])) {
        return 'uv';
    }
    // uv: [tool.uv] section in pyproject.toml
    const pyproject = await readTextFile(join(projectPath, 'pyproject.toml'));
    if (pyproject?.includes('[tool.uv]')) {
        return 'uv';
    }
    // Poetry: poetry.lock or [tool.poetry] in pyproject.toml
    if (await hasAnyFile(projectPath, ['poetry.lock'])) {
        return 'poetry';
    }
    if (pyproject?.includes('[tool.poetry]')) {
        return 'poetry';
    }
    // Hatch: hatch.toml or [tool.hatch] in pyproject.toml
    if (await hasAnyFile(projectPath, ['hatch.toml'])) {
        return 'hatch';
    }
    if (pyproject?.includes('[tool.hatch]')) {
        return 'hatch';
    }
    // Rye: .rye directory or rye.toml
    if (await hasAnyFile(projectPath, ['rye.toml', '.rye/config.toml'])) {
        return 'rye';
    }
    // pip: requirements.txt or setup.py
    if (await hasAnyFile(projectPath, ['requirements.txt', 'setup.py', 'setup.cfg'])) {
        return 'pip';
    }
    return null;
}
//# sourceMappingURL=python-pm-detector.js.map