Skip to main content

Update Python package versions in requirements.txt with exact versions from pip freeze

Project description

Pipup

Update Python Package versions in requirements.txt with exact versions from pip freeze

PyPI version License: MIT Python 3.7+

A command-line tool that updates existing packages in requirements.txt with their exact versions from pip freeze, without adding new packages. Perfect for keeping your requirements.txt files up-to-date with your current environment.

✨ Features

  • Safe Updates: Only updates existing packages, never adds new ones
  • Preserves Formatting: Maintains package order, comments, and empty lines
  • Smart Version Handling: Supports all version specifiers (>=, <, ~, etc.)
  • Package Extras: Correctly handles packages with extras (e.g., Flask[async])
  • Dry Run Mode: Preview changes before applying them
  • Enhanced Dry Run: Shows complete updated requirements.txt content
  • Error Handling: Warns about packages not found in pip freeze
  • Cross-Platform: Works on macOS, Linux, and Windows

🚀 Installation

Homebrew (macOS) - Recommended

brew install abozaralizadeh/brew/pipup

PyPI

pip install requp

Note: After installation, you can use either pipup or requp commands - they work identically!

From Source

git clone https://github.com/abozaralizadeh/pipup.git
cd pipup
pip install -e .

Direct Installation

pip install git+https://github.com/abozaralizadeh/pipup.git

📖 Usage

Basic Usage

pipup                                    # Update requirements.txt (default)
# or
requp                                    # Update requirements.txt (default)

Dry Run (Preview Changes)

pipup --dry-run                          # Preview changes to requirements.txt
# or
requp --dry-run                          # Preview changes to requirements.txt

Update Different Requirements Files

pipup requirements-dev.txt               # Update specific file
pipup requirements-prod.txt              # Update specific file
pipup requirements-test.txt              # Update specific file
# or use requp instead of pipup

Get Help

pipup --help
pipup --version
# or
requp --help
requp --version

🎛️ Skip Conventions

Pipup supports special comment conventions to control which packages get updated:

Skip Single Package

# This package should not be updated
#skip-pipup
requests==2.31.0

# Or use the requp alias
#skip-requp
Flask>=2.0.0

Skip All Remaining Packages

# Everything below this line should be ignored
#stop-pipup
pydantic==1.10.15
azure-storage-blob==12.19.1
# This comment will also be preserved

Supported Conventions

  • #skip-pipup or #skip-requp - Skip the next package line
  • #stop-pipup or #stop-requp - Skip all remaining lines

📋 Examples

Before Running Pipup

requests
Flask>=2.0.0
langchain
pydantic>=1.0.0,<2.0.0
# This is a comment
azure-storage-blob
Flask[async]
duckduckgo-search

After Running Pipup

requests==2.32.4
Flask==3.1.1
langchain==0.3.27
pydantic==2.11.7
# This is a comment
azure-storage-blob==12.26.0
Flask[async]==3.1.1
duckduckgo-search

Dry Run Output

$ pipup --dry-run
Running pip freeze...
Found 246 installed packages
Dry run: Updating test_requirements.txt...
Warning: flask not found in pip freeze, keeping original specification
Warning: duckduckgo-search not found in pip freeze, keeping original specification

Dry run: Would update 4 packages
Packages not found in pip freeze: flask, duckduckgo-search

Updated requirements.txt content:
--------------------------------------------------
requests==2.31.0
Flask>=2.0.0
langchain==0.0.329
pydantic==1.10.15
# This is a comment
azure-storage-blob==12.19.1
Flask[async]
duckduckgo-search
--------------------------------------------------

🔧 How It Works

  1. Runs pip freeze to get all installed packages with exact versions
  2. Parses requirements.txt line by line, preserving formatting and comments
  3. Matches packages by name (case-insensitive) and handles extras
  4. Updates version specifiers to exact versions (==) from pip freeze
  5. Preserves everything else (comments, empty lines, package order, warnings)

📦 Supported Version Specifiers

Pipup handles all standard pip version specifiers:

Specifier Example Result
No version requests requests==2.32.4
Exact version requests==1.0.0 requests==2.32.4
Minimum version requests>=1.0.0 requests==2.32.4
Maximum version requests<3.0.0 requests==2.32.4
Version range requests>=1.0.0,<3.0.0 requests==2.32.4
Compatible release requests~=1.0.0 requests==2.32.4
Exclusion requests!=1.0.0 requests==2.32.4

🎯 Package Extras Support

Pipup correctly handles packages with extras:

# Before
Flask[async]
requests[security]
django[postgresql]

# After
Flask[async]==3.1.1
requests[security]==2.32.4
django[postgresql]==4.2.7

⚠️ Error Handling

  • Missing requirements.txt: Exits with clear error message
  • Package not found: Warns and keeps original specification
  • pip not found: Exits with helpful error message
  • Invalid requirements.txt: Preserves malformed lines as-is
  • Permission errors: Clear error messages for file access issues

🛠️ Development

Setup Development Environment

git clone https://github.com/abozaralizadeh/pipup.git
cd pipup
pip install -e .

Running Tests

python -m pytest tests/

Building Package

python -m build

📝 Changelog

1.0.9

  • Default File: Added default value for requirements.txt file
  • Simplified Usage: Can now run pipup or requp without specifying file
  • Skip Conventions: Added #skip-pipup/#skip-requp and #stop-pipup/#stop-requp comments
  • Fine-grained Control: Users can now skip individual packages or all remaining packages
  • Better UX: More intuitive for common use case
  • Updated Documentation: Examples now show default behavior and skip conventions

1.0.9

  • GitHub Permissions: Fixed GitHub Actions release permissions
  • Release Attachments: Added built packages to GitHub releases

1.0.7

  • Better Permissions: Added explicit contents: write permissions
  • Improved Workflow: Enhanced CI/CD pipeline reliability

1.0.6

  • CI/CD Fixes: Fixed GitHub Actions build and upload process
  • Build Verification: Added steps to verify dist/ contents before upload
  • Clean Builds: Ensures fresh builds without cached files
  • Better Debugging: Added logging to track build process

1.0.5

  • Workflow Fixes: Fixed GitHub Actions release workflow permissions
  • Modern Actions: Updated to use softprops/action-gh-release@v1
  • Auto Changelog: Added automatic release notes generation
  • Better Reliability: Improved CI/CD pipeline stability

1.0.3

  • Command Alias: Added requp as an alias command for PyPI users
  • Dual Commands: Users can now use either pipup or requp commands
  • Enhanced Documentation: Updated README with comprehensive examples and badges
  • Improved Workflow: Fixed GitHub Actions release workflow
  • Better User Experience: More intuitive for users installing from PyPI

1.0.2

  • PyPI Package Name: Changed to requp to avoid naming conflicts
  • Enhanced Dry Run: Now shows complete updated requirements.txt content
  • Improved Documentation: Better examples and clearer instructions
  • Homebrew Support: Added Homebrew installation via repository

1.0.1

  • Enhanced Dry Run: Added display of updated requirements.txt content
  • Better Error Messages: Improved warning and error output
  • Documentation Updates: Added comprehensive examples

1.0.0

  • Initial Release: Basic package version updating
  • Dry Run Mode: Preview changes before applying
  • Version Specifier Support: All standard pip version specifiers
  • Package Extras Support: Handles packages with extras correctly
  • Cross-Platform: Works on macOS, Linux, and Windows

🤝 Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests if applicable
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Inspired by the need for safe requirements.txt updates
  • Built with Python's excellent packaging tools
  • Thanks to all contributors and users

📞 Support


Made with ❤️ for the Python community

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

requp-1.0.9.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

requp-1.0.9-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file requp-1.0.9.tar.gz.

File metadata

  • Download URL: requp-1.0.9.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for requp-1.0.9.tar.gz
Algorithm Hash digest
SHA256 20b38017730c4864c5258737bc47ff0eccdd498730d643af83df8e1b3fd3f7c8
MD5 4dfcbef74c8c2ea7d384dbc08be7e39c
BLAKE2b-256 b7e4b87d846558fd3fbc0478b9aa03abc3be182d99d41bbd76a2ea5d3884ef64

See more details on using hashes here.

File details

Details for the file requp-1.0.9-py3-none-any.whl.

File metadata

  • Download URL: requp-1.0.9-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for requp-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 46e0e6089eb6cb76a6f323204c01bedededdb8e97388f15d9b3fcfe1f38647b5
MD5 9752f2c8e5f0a635c6316a8730522ca8
BLAKE2b-256 97e9bba7e3c65756217682a7bd130b636d4a2b13a779330f4c9faaca856733da

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