Skip to main content

Upgrade only direct dependencies in requirements.txt or pyproject.toml

Project description

upgrade-py-direct-reqs

Upgrade only direct dependencies listed in requirements.txt safely.

A Python CLI tool that lets you review and upgrade only direct dependencies in a project’s requirements.txt or pyproject.toml, while keeping your pinned versions up to date.

Developed by coding agents with guidance from Miteshkumar N Raval.

Features

  • Lists outdated direct dependencies.
  • Prompts for confirmation before upgrading.
  • Supports both requirements.txt and pyproject.toml (with [project.dependencies]).
  • Updates requirements.txt with new pinned versions.
  • Cross-platform: works on Linux, macOS, and Windows.
  • CLI installable via pip in a virtual environment or globally.

Installation

# Recommended: install inside your existing project virtual environment
source myenv/bin/activate  # or myenv\Scripts\activate on Windows
pip install upgrade-py-direct-reqs

# Optional: install the CLI globally with pipx
pipx install upgrade-py-direct-reqs

Important: Even when installed via pipx, activate your project's virtual environment before running upgrade-py-direct-reqs so upgrades are applied to the correct environment.


Usage

# Explicitly specify your requirements file
upgrade-py-direct-reqs requirements.txt

# Or specify your pyproject.toml
upgrade-py-direct-reqs pyproject.toml
  • The CLI lists outdated direct dependencies.
  • Review versions and confirm before upgrading.
  • After upgrade, the requirements.txt file is updated with pinned versions.

Example

Before

requirements.txt:

requests==2.30.0
flask==2.2.5

Command

upgrade-py-direct-reqs requirements.txt

Output (sample)

📦 Outdated direct dependencies:

  requests: 2.30.0 → 2.32.3
  flask: 2.2.5 → 3.0.3

⚠️  Please review package revisions listed above before upgrading.
   Check release notes on pypi.org for BREAKING changes or necessary code updates.

Proceed with upgrade? (y/n): y
⬆️  Upgrading 2 packages...
✅ Requirements updated: requirements.txt

After

requirements.txt:

requests==2.32.3
flask==3.0.3

Test instructions

To run CLI tests with pytest:

 1. pip install .[dev]  (to install dev deps listed in pyproject.toml)
 2. Ensure pytest is installed in your environment: pip install pytest
 3. Run tests from the project root:
       pytest tests/tests_cli.py
 4. Tests cover:
       - requirements.txt only
       - pyproject.toml only
       - conflicting dependencies in both files
       - empty requirements.txt
       - invalid toml file name (refer PEP 621 for more details)

License

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

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

upgrade_py_direct_reqs-0.3.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

upgrade_py_direct_reqs-0.3.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file upgrade_py_direct_reqs-0.3.0.tar.gz.

File metadata

  • Download URL: upgrade_py_direct_reqs-0.3.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for upgrade_py_direct_reqs-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b1ee8f200ad0f9320183af2ed843fb1d9f1466c740ecd7709c9f6a2f3fb1a811
MD5 6b2ff4db1dd3b4ce4cbed6fa39fe0e43
BLAKE2b-256 05cedc8e89145c0e874712312128ce4abe47e0290f56dec97fa9a5f4bb8d8f95

See more details on using hashes here.

File details

Details for the file upgrade_py_direct_reqs-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for upgrade_py_direct_reqs-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a23221e0631ceab4af4fc55b429f7acf42e96ca79507c49add32cf87a3ab066e
MD5 ff306acfa255cf8d172d34c5a4751aca
BLAKE2b-256 390a3e1ab3d25ae2d663258c38914f6b76224b3438c798179e374b458da149fc

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