{"id":5817,"library":"requirements-detector","title":"Requirements Detector","description":"requirements-detector is a simple Python tool designed to find and list the dependencies of a Python project. It analyzes various common project files to ascertain required libraries and their versions. The current version is 1.5.0, and it appears to be under active development with periodic updates.","status":"active","version":"1.5.0","language":"en","source_language":"en","source_url":"https://github.com/prospector-dev/requirements-detector","tags":["requirements","dependencies","project analysis","packaging","pip"],"install":[{"cmd":"pip install requirements-detector","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Runtime dependency for parsing Python code to detect imports.","package":"astroid","optional":false},{"reason":"Used for parsing and working with version specifiers.","package":"packaging","optional":false},{"reason":"Used for semantic versioning comparisons.","package":"semver","optional":false}],"imports":[{"symbol":"find_requirements","correct":"from requirements_detector import find_requirements"},{"symbol":"from_requirements_txt","correct":"from requirements_detector import from_requirements_txt"},{"symbol":"from_setup_py","correct":"from requirements_detector import from_setup_py"},{"symbol":"from_pyproject_toml","correct":"from requirements_detector import from_pyproject_toml"}],"quickstart":{"code":"import os\nfrom requirements_detector import find_requirements\n\n# Detect requirements in the current working directory\ndetected_reqs = find_requirements(os.getcwd())\n\nfor req in detected_reqs:\n    print(f\"Detected: {req.name} {req.specifier}\")\n\n# Example for a specific requirements.txt file\n# from requirements_detector import from_requirements_txt\n# reqs_from_file = from_requirements_txt(\"/path/to/your/project/requirements.txt\")\n# for req in reqs_from_file:\n#     print(f\"From file: {req.name} {req.specifier}\")","lang":"python","description":"This quickstart demonstrates how to use `find_requirements` to automatically detect dependencies in a given directory, typically the root of a Python project. It identifies requirements by inspecting common files like `setup.py`, `pyproject.toml`, and various `requirements.txt` patterns. Alternatively, specific parsing functions like `from_requirements_txt` can be used for explicit file paths."},"warnings":[{"fix":"Ensure your primary dependency declaration method (e.g., `setup.py` or `pyproject.toml`) is correctly configured, or if relying on `requirements.txt`, understand its position in the parsing hierarchy. Use the API functions like `from_requirements_txt` for explicit file parsing if the auto-detection order is not desired.","message":"The detector prioritizes parsing order: `setup.py` first, then `pyproject.toml` (specifically `tool.poetry.dependencies`), followed by `requirements.txt`, `requirements.pip`, and other `*.txt`/`*.pip` files in a 'requirements' folder or the root. Users should be aware of this order, as requirements found earlier will prevent later files from being parsed.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For complex dependency graphs, consider complementing `requirements-detector` with dedicated dependency resolution tools like `pip-tools` or `Poetry`. Always manually verify the detected requirements against your project's actual runtime needs.","message":"The tool is described as 'simple' and primarily focuses on finding and listing requirements. It might not robustly handle highly complex, unconventional project structures, or advanced dependency resolution scenarios beyond its defined parsing mechanisms. It does not perform full dependency resolution or conflict detection.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For programmatic access to detected requirements, import and use the Python functions directly (e.g., `from requirements_detector import find_requirements`). Avoid parsing the CLI output if structured data is critical.","message":"When used via the command-line interface (`detect-requirements`), the output is plaintext, formatted to resemble a standard `pip requirements` file. If you need structured data (e.g., for further programmatic processing), you must use the Python API, specifically the `find_requirements` function or other `from_*` functions, which return `DetectedRequirement` objects.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}