Dependency and environment checker tool
Project description
depvex
Depvex is a small Python tool that helps manage a project's dependencies based on the imports used in its Python source code.
It performs three main tasks:
- Scans Python files in the project and detects third-party imports.
- Creates or updates the requirements.txt file based on the modules found.
- Watches the project for changes and re-runs the scan automatically.
What it does
This tool is especially useful when you want to generate requirements.txt quickly and accurately without writing it manually.
It works like this:
- Reads all .py files in the project
- Extracts imports that are not part of the Python standard library
- Tries to resolve each module into a requirements entry
- If the module is installed locally, it uses the locally installed version
- If it is not installed and the network is available, it checks the latest version on PyPI
- Otherwise, it writes just the module name without a version
Main features
- Automatic detection of Python imports
- Creation and updating of requirements.txt
- Watch mode support for automatic re-scanning on file changes
- Ignores directories such as .git, pycache, .venv, venv, and node_modules
- Supports version resolution from local installs or PyPI
Project structure
- cli.py – CLI entry point
- parser.py – Extracts imports from Python code
- resolver.py – Resolves modules into requirements entries
- watcher.py – Watches files for changes
System requirements
- Python 3.11
- pip
- Internet access (optional, only needed if you want to query PyPI for versions)
Installation
1) Clone the project
git clone <repository-url>
cd depix
2) Create a virtual environment (recommended)
python3.11 -m venv .venv
source .venv/bin/activate
3) Install the project
python3.11 -m pip install --upgrade pip
python3.11 -m pip install -e .
This will also install the required dependencies, including:
- watchdog
- requests
- typer
How to run it
Basic mode: one-time scan
If you want to create or update requirements.txt based on the code currently in the project, run:
depvex watch .
This will start watching your code for changes and update requirements.txt whenever a Python file changes.
Running against another path
depvex watch ./my-project
Example
Suppose you have a Python file like this:
import requests
import os
from pathlib import Path
After running depvex, requirements.txt may be updated to something like:
requests==2.32.3
The exact output depends on the locally installed version or the latest version available on PyPI.
How watch mode works
In this mode:
- The tool listens for changes in files ending in .py
- When it detects a change, it re-scans the project
- It regenerates requirements.txt
This is especially useful during development when you add or remove imports frequently.
requirements.txt format
The tool writes entries in the form:
package-name==1.2.3
or, if no version is found:
package-name
Packaging and publishing to PyPI
The project includes a GitHub Actions workflow that publishes it to PyPI when a tag starting with v is pushed.
To use this, you need:
- a secret named PYPI_TOKEN
- a tag in the following format:
git tag v0.0.1
git push origin v0.0.1
Important notes
- The tool is based on static analysis of imports, so it does not always detect dynamic imports perfectly.
- If a module is not installed and the network is unavailable, it will write only the module name without a version.
- This is a useful tool for generating an initial requirements.txt, but it is not a full replacement for dependency management tools such as poetry or uv in large projects.
Common issues
No depvex command found
The most common cause is that the project was not installed with pip install -e .
requirements.txt is not updated
Check whether:
- the file you changed is a .py file
- there is no syntax error in your code
- you are running watch mode from the correct project root
No version is shown for a module
This usually happens when:
- the module is not installed locally
- there is no internet access
- PyPI did not return version information for the module
Summary
Depvex is a simple and useful tool for generating requirements.txt automatically from Python source code, especially in fast-moving development environments.
If you want to get started quickly, run:
python3.11 -m pip install -e .
depvex watch .
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 depvex-0.1.1.tar.gz.
File metadata
- Download URL: depvex-0.1.1.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22f77126cebd2b0978823668276fa029a7ac21e7c0e61935c3c1c0dea510460b
|
|
| MD5 |
2d98e8e809ddd25a44146703182ad34f
|
|
| BLAKE2b-256 |
7dfd4c2b46d1b3e9ebee0462379709480db2c54588939b3afc808882c4b37d80
|
File details
Details for the file depvex-0.1.1-py3-none-any.whl.
File metadata
- Download URL: depvex-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f955de5ccb3f269446c4f7babb27a536406492b01b823a45d964340adbecc3c
|
|
| MD5 |
23b20de4f5683a3afbff56bb1423778b
|
|
| BLAKE2b-256 |
48470aaba2400433d300aea3fce64b53247471f695588048d8262b3c8580e5e8
|