Skip to main content

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

  1. Parse Requirements: Reads your requirements.txt file and extracts package names
  2. Create Environment: Sets up a new virtual environment (or uses existing)
  3. Install Packages: Installs the latest versions of all packages
  4. Freeze Versions: Uses pip freeze to get exact versions
  5. 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.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. 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


Download files

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

Source Distribution

req_updater-0.1.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

req_updater-0.1.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

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

Hashes for req_updater-0.1.0.tar.gz
Algorithm Hash digest
SHA256 62c59a2672bdfa12549fa905710deba160e2e3f387591cc152d4804f110151a1
MD5 3441a9e0d566cc686f11077bf8ad1cfb
BLAKE2b-256 fce84e47e6cf995aeaecbbd08e582c511f3f26dd87f3ec5e6ea8df07bd20e782

See more details on using hashes here.

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

Hashes for req_updater-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 84d393b749ccc0e490c11d9e93e3349ab5efc07773e0d5b551faae34ea2e9d1b
MD5 a49137705747a7ae60300dc02364e630
BLAKE2b-256 8379b5207b3ed4315f9f3d895c0751094a73c828bc4e74c405e27fe6f36b59d8

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