Scan project source files and populate requirements.txt – with PyPI search and interactive resolution.
Project description
python-auto-req
Scan your Python project's .py and .ipynb files, discover every third-party
package that is actually imported, and add them to requirements.txt.
Only packages explicitly referenced in your source files are considered. Packages installed in
.venvbut never imported are ignored.
Features
- Recursively scans
.pyand.ipynbfiles (skips.venv,.git,__pycache__, etc.) - Uses the active Python environment to resolve module → distribution name + version
- Falls back to a live PyPI search for unknown modules with an interactive menu:
- Pick from top-5 results ranked by n-gram similarity
- Auto-select top match (
[a]or--auto) - Enter a name manually (
[m]) - Skip (
[s]) or quit ([q])
- Offers to run
pip install -r requirements.txtafter writing
Installation
pip install python-auto-req
Or from source:
git clone https://github.com/Amit-Roy/python-auto-req
cd python-auto-req
pip install -e .
Usage
# Preview what would be added (dry-run, interactive)
auto-req
# Write requirements.txt
auto-req --dry-run 0
# Write requirements.txt, auto-pick top PyPI match for unknowns
auto-req --dry-run 0 --auto
# Scan a specific directory
auto-req --dir /path/to/project --dry-run 0
Or via Python:
python -m auto_req --dry-run 0
CLI options
| Option | Default | Description |
|---|---|---|
--dry-run 0|1 |
1 |
1 = preview only; 0 = write to file |
--auto |
off | Always pick the top PyPI match (no prompts) |
--dir DIR |
. |
Project root to scan |
--requirements FILE |
./requirements.txt |
Path to requirements.txt |
Interactive resolution example
Unrecognised module: 'yfinance'
Searching PyPI for 'yfinance'... 5 result(s).
Top PyPI matches:
[1] yfinance (similarity 1.00)
[2] yfinance-cache (similarity 0.78)
[3] yfinance-ez (similarity 0.72)
...
[1-5] select a match above
[a] auto-select top match for ALL remaining unknowns
[m] enter the correct dist name manually
[s] skip (omit from requirements, continue)
[q] quit (stop resolution now)
Your choice: 1
Development
pip install -e ".[dev]"
pytest
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 python_auto_req-0.4.0.tar.gz.
File metadata
- Download URL: python_auto_req-0.4.0.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14ab787c9a53a5bf720b7c13516d28b1fbffac14004bc2c968f61c94f0fd7527
|
|
| MD5 |
704ea93bcfc172c63721301d0680279f
|
|
| BLAKE2b-256 |
b5dc02da1abffbadfa4d0dbc7d153c235fc9fe5f40ea13621d75f76449e48cab
|
Provenance
The following attestation bundles were made for python_auto_req-0.4.0.tar.gz:
Publisher:
publish.yml on Amit-Roy/python-auto-req
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_auto_req-0.4.0.tar.gz -
Subject digest:
14ab787c9a53a5bf720b7c13516d28b1fbffac14004bc2c968f61c94f0fd7527 - Sigstore transparency entry: 1241985905
- Sigstore integration time:
-
Permalink:
Amit-Roy/python-auto-req@537e329538ea016cadda53146daa85161dfe1bb5 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/Amit-Roy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@537e329538ea016cadda53146daa85161dfe1bb5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file python_auto_req-0.4.0-py3-none-any.whl.
File metadata
- Download URL: python_auto_req-0.4.0-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2306fa5f79d3ad182f8966b8cabfb998b7e59425879d66e499c530671c7e42f
|
|
| MD5 |
5742405696f1313d0fd186ed490adb5d
|
|
| BLAKE2b-256 |
676b7224a6c4cf1dd80e0505b21dd8516aa947e36f78b101a21e160d87a86d3b
|
Provenance
The following attestation bundles were made for python_auto_req-0.4.0-py3-none-any.whl:
Publisher:
publish.yml on Amit-Roy/python-auto-req
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_auto_req-0.4.0-py3-none-any.whl -
Subject digest:
b2306fa5f79d3ad182f8966b8cabfb998b7e59425879d66e499c530671c7e42f - Sigstore transparency entry: 1241985906
- Sigstore integration time:
-
Permalink:
Amit-Roy/python-auto-req@537e329538ea016cadda53146daa85161dfe1bb5 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/Amit-Roy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@537e329538ea016cadda53146daa85161dfe1bb5 -
Trigger Event:
push
-
Statement type: