A CLI tool to install packages and manage requirements.txt in one command
Project description
pip-add
A command-line tool that combines package installation and requirements.txt management. Install, update, or remove Python packages and their dependencies with automatic requirements.txt handling.
Features
- Single command for package management and requirements.txt updates
- Smart dependency handling for installation and removal
- Dependency analysis to prevent breaking other packages
- Flexible version specifications (
>=by default) - Optional exact version pinning (
==) - Clean, informative output with version information
- Preserves requirements.txt comments and formatting
- Creates requirements.txt if it doesn't exist
Installation
# Install from PyPI
pip install pip-add
# Or install latest version
pip install --upgrade pip-add
Usage
Installation
# Basic package installation
pip-add requests
# Output:
# Installing requests...
# ✓ Successfully installed requests (2.32.3)
# ✓ Updated requirements.txt
# Install with exact version
pip-add -e requests
# Adds: requests==2.32.3 to requirements.txt
# Install with dependencies
pip-add -d requests
# Output:
# Installing requests...
# ✓ Successfully installed:
# - certifi (2024.8.30)
# - charset-normalizer (3.4.0)
# - idna (3.10)
# - requests (2.32.3)
# - urllib3 (2.2.3)
# ✓ Updated requirements.txt
Removal
# Remove single package
pip-add -r requests
# Output:
# Removing packages...
# ✓ Successfully uninstalled requests (2.32.3)
# ✓ Updated requirements.txt
# Remove package and its unused dependencies
pip-add -d -r requests
# Output:
# Removing packages...
# ✓ Successfully uninstalled:
# - certifi (2024.8.30)
# - charset-normalizer (3.4.0)
# - requests (2.32.3)
# - urllib3 (2.2.3)
#
# ℹ️ Dependencies kept (required by other packages):
# - idna (needed by: email-validator, cryptography)
#
# ✓ Updated requirements.txt
Command Line Options
pip-add [-h] [-d] [-e] [-r] package
positional arguments:
package Package to install or remove
options:
-h, --help show this help message and exit
-d, --dependencies Include dependencies when installing or removing
-e, --exact Use == instead of >= for version specification
-r, --remove Remove package(s) and their entries from requirements.txt
How It Works
Installation Process
- Installs the specified package using pip
- Retrieves installed version information
- With
-d: tracks and installs all dependencies - Updates requirements.txt with new package(s)
- Uses
>=by default or==with-eflag
Removal Process
- Analyzes package dependencies
- Identifies which dependencies are safe to remove
- Checks if any dependencies are needed by other packages
- Safely removes unused packages
- Updates requirements.txt
- Reports kept dependencies and their dependents
Safe Dependency Handling
The tool is designed to safely handle dependencies:
- Installation: Records all dependencies when using
-d - Removal: Only removes dependencies that aren't needed by other packages
- Analysis: Shows which dependencies were kept and why
- Protection: Prevents breaking other installed packages
Requirements
- Python 3.6+
- pip
- setuptools
Development
Local Setup
# Clone the repository
git clone https://github.com/PacNPal/pip-add.git
cd pip-add
# Create virtual environment
python -m venv venv
source venv/bin/activate # or `venv\Scripts\activate` on Windows
# Install in development mode
pip install -e .
Common Scenarios
New Project
# First time setup
pip-add -d flask
# Creates requirements.txt and adds Flask with dependencies
Updating Dependencies
# Update with newer versions
pip-add requests
# Updates to newest version with >= specification
Clean Uninstall
# Remove package and unused dependencies
pip-add -d -r flask
# Removes Flask and dependencies not used by other packages
Troubleshooting
-
Package not found in requirements.txt
- The file will be created automatically
- Existing comments are preserved
-
Dependency conflicts
- Uses
>=by default to minimize conflicts - Use
-efor exact versions when needed
- Uses
-
Dependencies not removing
- Check the output for dependencies kept
- Tool will show which packages need them
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
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 pip_add-0.1.1.tar.gz.
File metadata
- Download URL: pip_add-0.1.1.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfb2b8d044bce359cb78218d5961c981c903b0ea8305ff0e15ff1a376e7e7a2f
|
|
| MD5 |
e45c795dd62cef54125be5c3ac8a9d99
|
|
| BLAKE2b-256 |
479aa2ae355f382f972d2772b18a2dd5fdd3b92da29b354536a72c8ddf77a553
|
Provenance
The following attestation bundles were made for pip_add-0.1.1.tar.gz:
Publisher:
publish.yml on pacnpal/pip-add
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pip_add-0.1.1.tar.gz -
Subject digest:
cfb2b8d044bce359cb78218d5961c981c903b0ea8305ff0e15ff1a376e7e7a2f - Sigstore transparency entry: 149882844
- Sigstore integration time:
-
Permalink:
pacnpal/pip-add@00e886eb59701ed548f52d5db353497d1454a23c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/pacnpal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@00e886eb59701ed548f52d5db353497d1454a23c -
Trigger Event:
release
-
Statement type:
File details
Details for the file pip_add-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pip_add-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17f5a9acff994dae1a2fc11c329d2528a9c874dad8f5c65d810897132c561551
|
|
| MD5 |
57b797d6feefeb989c67dcf593433b7a
|
|
| BLAKE2b-256 |
085db6e53c50519b9d4bde0d5cc584112772eea72b5f6fe63595a20501a0d529
|
Provenance
The following attestation bundles were made for pip_add-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on pacnpal/pip-add
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pip_add-0.1.1-py3-none-any.whl -
Subject digest:
17f5a9acff994dae1a2fc11c329d2528a9c874dad8f5c65d810897132c561551 - Sigstore transparency entry: 149882845
- Sigstore integration time:
-
Permalink:
pacnpal/pip-add@00e886eb59701ed548f52d5db353497d1454a23c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/pacnpal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@00e886eb59701ed548f52d5db353497d1454a23c -
Trigger Event:
release
-
Statement type: