Skip to content

Python Package Installer for Debian - Bridge between APT and PyPI

License

Notifications You must be signed in to change notification settings

sansnom-co/pipd

Repository files navigation

PIPD - Python Package Installer for Debian

License: MIT Python Version Debian Ubuntu

PIPD is an advanced Python package management tool designed specifically for Debian-based systems. It bridges the gap between system package management (APT) and Python package management (PyPI), prioritizing system packages when available while providing seamless fallback to PyPI.

🌟 Key Features

  • πŸ” Intelligent Package Resolution: Automatically checks Debian repositories before PyPI
  • πŸš€ Familiar CLI Interface: Uses pip-like commands for ease of use
  • πŸ›‘οΈ Transaction Support: Automatic rollback on installation failures
  • πŸ“¦ Package Conversion: Converts PyPI packages to .deb format for system integration
  • πŸ”’ Security First: Input validation, privilege checking, and safe execution
  • ⚑ Performance: Built-in caching to reduce redundant network calls
  • 🎯 PEP 668 Compliant: Works with externally managed Python environments

πŸ“‹ Table of Contents

πŸ€” Why PIPD?

Modern Debian/Ubuntu systems implement PEP 668, which prevents pip from installing packages system-wide to avoid conflicts. PIPD solves this by:

  1. Prioritizing system packages: Safer and more stable
  2. Converting PyPI packages: Creates proper .deb packages
  3. Managing dependencies: Handles conflicts between system and PyPI packages
  4. Providing rollback: Failed installations don't leave your system broken

πŸš€ Installation

Prerequisites

  • Debian-based system (Debian 11+, Ubuntu 20.04+)
  • Python 3.8 or higher
  • Root privileges for installation

Quick Install

# Clone the repository
git clone https://github.com/mestadler/pipd.git
cd pipd

# Run the installer
sudo ./install-pipd.sh

The installer will:

  • Detect available Python versions
  • Install system dependencies
  • Set up the PIPD environment
  • Configure logging and permissions

Manual Installation

See docs/INSTALL.md for detailed manual installation instructions.

πŸ“– Usage

Basic Commands

# Install packages
sudo pipd install requests numpy pandas

# Install specific version
sudo pipd install django==4.2

# Install from requirements file
sudo pipd install -r requirements.txt

# List installed packages
pipd list

# Show package information
pipd show requests

# Uninstall packages
sudo pipd uninstall requests

Advanced Usage

# Force reinstall
sudo pipd install --force-reinstall numpy

# Upgrade packages
sudo pipd install --upgrade django

# List with different formats
pipd list --format json
pipd list --format simple

# Verbose mode for debugging
sudo pipd -v install tensorflow

βš™οΈ Configuration

PIPD uses a TOML configuration file located at /etc/pipd/config.toml:

[general]
prefer_system_packages = true
cache_ttl = 3600
verbose = false

[sources]
check_debian_first = true
allow_pypi_fallback = true

[security]
verify_checksums = true
safe_mode = true

User-specific configuration can be placed in ~/.config/pipd/config.toml.

πŸ— Architecture

PIPD follows a modular architecture:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    CLI Interface                     β”‚
β”‚                  (Click-based CLI)                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                 PipdOrchestrator                     β”‚
β”‚         (Main coordination component)                β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚          β”‚             β”‚          β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β” β”Œβ”€β”€β”΄β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β” β”Œβ”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Package   β”‚ β”‚Debian   β”‚ β”‚ PyPI    β”‚ β”‚Dependency β”‚
β”‚ Resolver  β”‚ β”‚Manager  β”‚ β”‚Manager  β”‚ β”‚ Resolver  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Components

  • PackageResolver: Resolves packages across Debian and PyPI sources
  • DebianPackageManager: Handles APT operations
  • PyPIPackageManager: Downloads and converts PyPI packages
  • DependencyResolver: Manages dependency conflicts
  • InstallationTransaction: Provides rollback capability

πŸ”§ Troubleshooting

Common Issues

PEP 668 Error

error: externally-managed-environment

This is expected! PIPD is designed to work with this restriction by converting packages to .deb format.

Permission Denied

Error: This script requires root privileges

Solution: Use sudo pipd install <package>

Package Not Found

PIPD searches Debian repositories first. If a package isn't found:

  1. Check the package name spelling
  2. Update package lists: sudo apt update
  3. The package might only be available on PyPI

Debug Mode

Enable verbose logging for troubleshooting:

sudo pipd -v install <package>

Check logs at /var/log/pipd.log for detailed information.

🀝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Setup

# Clone the repository
git clone https://github.com/mestadler/pipd.git
cd pipd

# Create virtual environment
python3 -m venv venv
source venv/bin/activate

# Install development dependencies
pip install -r requirements-dev.txt

# Run tests
python -m pytest tests/

πŸ“Š Comparison with Other Tools

Feature PIPD pip pipx apt
System package priority βœ… ❌ ❌ βœ…
PyPI packages βœ… βœ… βœ… ❌
.deb conversion βœ… ❌ ❌ N/A
Transaction rollback βœ… ❌ ❌ βœ…
PEP 668 compliant βœ… ❌ βœ… N/A

πŸ›‘οΈ Security

PIPD implements several security measures:

  • Input validation for package names
  • Privilege checking before system modifications
  • Secure subprocess execution
  • Optional checksum verification

πŸ“„ License

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

πŸ™ Acknowledgments

  • Debian packaging team for the robust APT system
  • Python Software Foundation for pip and venv
  • py2deb and stdeb developers for package conversion tools
  • Click developers for the excellent CLI framework

πŸ“ž Support


Made with ❀️ for the Debian/Ubuntu Python community

πŸ“š Documentation

πŸ“ Project Structure

pipd/ β”œβ”€β”€ pipd # Main executable β”œβ”€β”€ install-pipd.sh # Installation script β”œβ”€β”€ install-python312-debian.sh # Python 3.12 installer β”œβ”€β”€ README.md # This file β”œβ”€β”€ LICENSE # MIT License β”œβ”€β”€ CONTRIBUTING.md # Contribution guidelines β”œβ”€β”€ docs/ # Documentation β”‚ β”œβ”€β”€ INSTALL.md # Installation guide β”‚ β”œβ”€β”€ MANUAL.md # User manual β”‚ β”œβ”€β”€ PEP668.md # PEP 668 explanation β”‚ └── PYTHON_COMPATIBILITY.md β”œβ”€β”€ examples/ # Example configurations β”‚ β”œβ”€β”€ config.toml.example β”‚ └── requirements-example.txt β”œβ”€β”€ tests/ # Test suite β”‚ └── test_pipd.py └── scripts/ # Utility scripts β”œβ”€β”€ fix-pipd.sh └── github-script.sh

About

Python Package Installer for Debian - Bridge between APT and PyPI

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published