Requirements Detector

1.5.0 · active · verified Tue Apr 14

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.

Warnings

Install

Imports

Quickstart

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.

import os
from requirements_detector import find_requirements

# Detect requirements in the current working directory
detected_reqs = find_requirements(os.getcwd())

for req in detected_reqs:
    print(f"Detected: {req.name} {req.specifier}")

# Example for a specific requirements.txt file
# from requirements_detector import from_requirements_txt
# reqs_from_file = from_requirements_txt("/path/to/your/project/requirements.txt")
# for req in reqs_from_file:
#     print(f"From file: {req.name} {req.specifier}")

view raw JSON →