Automatically updates package versions in requirements.txt files
Project description
req-updater
Automatically update package versions in requirements.txt files with the latest available versions from PyPI.
Overview
req-updater is a Python package that simplifies dependency management by automatically:
- Reading and parsing requirements.txt files
- Removing version specifiers to get the latest versions
- Creating and managing virtual environments
- Installing the latest package versions
- Generating updated requirements.txt files with exact versions
- Providing detailed progress output
Installation
From PyPI (when published)
pip install req-updater
From Source
git clone https://github.com/Sohail342/req-updater.git
cd req-updater
pip install -e .
Quick Start
# Basic usage - update requirements.txt in current directory
req-updater
# Update a specific requirements file
req-updater -r dev-requirements.txt
# Use a custom virtual environment path
req-updater --venv .myenv
# Enable verbose output for debugging
req-updater -v
# Remove virtual environment after updating
req-updater --cleanup
Features
- Automatic Updates: Updates all packages to their latest compatible versions
- Cross-Platform: Works on Windows, Linux, and macOS
- Virtual Environment Management: Automatically creates and manages virtual environments
- Clean Requirements: Generates clean requirements.txt with exact versions
- Error Handling: Comprehensive error handling with helpful messages
- Verbose Mode: Detailed progress output for debugging
- Backup Creation: Automatically creates backups of original requirements files
- CLI Interface: Easy-to-use command-line interface with help documentation
Command-Line Interface
Usage
req-updater [OPTIONS]
Options
| Option | Description | Example |
|---|---|---|
-r, --requirements |
Path to requirements file | -r dev.txt |
--venv |
Custom virtual environment path | --venv .env |
-v, --verbose |
Enable verbose output | -v |
--cleanup |
Remove virtual environment after update | --cleanup |
--version |
Show version information | --version |
-h, --help |
Show help message | -h |
Examples
# Update requirements.txt in current directory
req-updater
# Update specific file with verbose output
req-updater -r requirements-dev.txt -v
# Use custom virtual environment
req-updater --venv .venv
# Update and cleanup virtual environment
req-updater --cleanup
Python API
You can also use req-updater programmatically:
from req_updater import RequirementsUpdater
# Basic usage
updater = RequirementsUpdater()
updater.run()
# Custom paths
updater = RequirementsUpdater(
requirements_path='dev-requirements.txt',
venv_path='.myenv'
)
updater.run(verbose=True)
# Get installed versions
versions = updater.get_installed_versions()
print(versions)
# Cleanup virtual environment
updater.cleanup_venv()
Requirements
- Python 3.7 or higher
- setuptools 42 or higher
- packaging library (automatically installed)
Development
Setting up Development Environment
git clone https://github.com/Sohail342/req-updater.git
cd req-updater
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -e .[dev]
Running Tests
pytest
Building Package
python -m build
How It Works
- Parse Requirements: Reads your requirements.txt file and extracts package names
- Create Environment: Sets up a new virtual environment (or uses existing)
- Install Packages: Installs the latest versions of all packages
- Freeze Versions: Uses
pip freezeto get exact versions - Update File: Writes the updated requirements back to your file
Error Handling
The package includes comprehensive error handling for:
- Missing requirements files
- Invalid file formats
- Network connectivity issues
- Permission errors
- Virtual environment creation failures
- Package installation failures
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information
- Include your operating system, Python version, and error messages
Changelog
0.1.0 (Initial Release)
- Basic requirements.txt updating functionality
- Cross-platform support (Windows, Linux, macOS)
- CLI interface with argument parsing
- Virtual environment management
- Comprehensive error handling
- Verbose mode for debugging
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 req_updater-0.1.0.tar.gz.
File metadata
- Download URL: req_updater-0.1.0.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62c59a2672bdfa12549fa905710deba160e2e3f387591cc152d4804f110151a1
|
|
| MD5 |
3441a9e0d566cc686f11077bf8ad1cfb
|
|
| BLAKE2b-256 |
fce84e47e6cf995aeaecbbd08e582c511f3f26dd87f3ec5e6ea8df07bd20e782
|
File details
Details for the file req_updater-0.1.0-py3-none-any.whl.
File metadata
- Download URL: req_updater-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84d393b749ccc0e490c11d9e93e3349ab5efc07773e0d5b551faae34ea2e9d1b
|
|
| MD5 |
a49137705747a7ae60300dc02364e630
|
|
| BLAKE2b-256 |
8379b5207b3ed4315f9f3d895c0751094a73c828bc4e74c405e27fe6f36b59d8
|