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:
- Scan all Python files in the current directory and subdirectories
- Detect third-party imports
- Map import names to correct package names (e.g., 'yaml' → 'PyYAML')
- 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:
yaml→PyYAMLdotenv→python-dotenvPIL→Pillowsklearn→scikit-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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d08c5a040a1d7b12babe2f0857f83747ed4c58dcb3a5d6f8e5fe8b4013edb64
|
|
| MD5 |
d26b639a602bdfc981a5dbdc902bd15b
|
|
| BLAKE2b-256 |
a7e7f2a13415302d7877f201a92f655b3c0f39fff0bedae0d1dce77c9f1e9897
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c2deceba594f3067f04bbe8e102ba9c4e418b87c7c63ba1ce02ff8bd2d5f3cf
|
|
| MD5 |
5e2adbf134a700467ee1ae301ede0d1d
|
|
| BLAKE2b-256 |
76c8508192ad327dbb34dfe7ab8949199a6a0a5908357bc8824986bf71415a77
|