Skip to main content

A tool to automatically detect Python project dependencies and generate requirements.txt

Project description

Python Dependencies Generator

A simple tool to automatically detect Python project dependencies and generate requirements.txt. It analyzes your Python files recursively, detects imports, and handles common package name mappings (like 'yaml' → 'PyYAML').

Installation

pip install gen-reqs

Usage

From the command line:

gen_reqs

This will:

  1. Scan all Python files in the current directory and subdirectories
  2. Detect third-party imports
  3. Map import names to correct package names (e.g., 'yaml' → 'PyYAML')
  4. Generate a requirements.txt file

Features

  • Recursive scanning of Python files
  • Automatic detection of third-party imports
  • Mapping of common import names to correct package names
  • Filtering out standard library modules
  • Detection of local modules (to exclude them)

Common Package Mappings

The tool handles many common package name mappings, including:

  • yamlPyYAML
  • dotenvpython-dotenv
  • PILPillow
  • sklearnscikit-learn
  • And many more...

As a Python Module

You can also use it in your Python code:

from python_deps_generator import generate_requirements

# Generate requirements.txt in current directory
generate_requirements()

# Or specify a directory
generate_requirements("/path/to/project")

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gen_reqs-0.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gen_reqs-0.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file gen_reqs-0.1.0.tar.gz.

File metadata

  • Download URL: gen_reqs-0.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for gen_reqs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2d08c5a040a1d7b12babe2f0857f83747ed4c58dcb3a5d6f8e5fe8b4013edb64
MD5 d26b639a602bdfc981a5dbdc902bd15b
BLAKE2b-256 a7e7f2a13415302d7877f201a92f655b3c0f39fff0bedae0d1dce77c9f1e9897

See more details on using hashes here.

File details

Details for the file gen_reqs-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: gen_reqs-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for gen_reqs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9c2deceba594f3067f04bbe8e102ba9c4e418b87c7c63ba1ce02ff8bd2d5f3cf
MD5 5e2adbf134a700467ee1ae301ede0d1d
BLAKE2b-256 76c8508192ad327dbb34dfe7ab8949199a6a0a5908357bc8824986bf71415a77

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page