An open API service indexing awesome lists of open source software.

https://github.com/mestadler/pipd

Python Package Installer for Debian - Bridge between APT and PyPI
https://github.com/mestadler/pipd

apt debian package-manager package-manager-tool pep668 pip pipx python3 ubuntu

Last synced: 9 months ago
JSON representation

Python Package Installer for Debian - Bridge between APT and PyPI

Awesome Lists containing this project

README

          

# PIPD - Python Package Installer for Debian

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python Version](https://img.shields.io/badge/python-3.8%2B-blue)](https://www.python.org/downloads/)
[![Debian](https://img.shields.io/badge/Debian-compatible-red)](https://www.debian.org/)
[![Ubuntu](https://img.shields.io/badge/Ubuntu-compatible-orange)](https://ubuntu.com/)

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?](#-why-pipd)
- [Installation](#-installation)
- [Usage](#-usage)
- [Configuration](#%EF%B8%8F-configuration)
- [Architecture](#-architecture)
- [Troubleshooting](#-troubleshooting)
- [Contributing](#-contributing)
- [License](#-license)

## πŸ€” 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

```bash
# 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](docs/INSTALL.md) for detailed manual installation instructions.

## πŸ“– Usage

### Basic Commands

```bash
# 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

```bash
# 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`:

```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
```bash
error: externally-managed-environment
```
This is expected! PIPD is designed to work with this restriction by converting packages to .deb format.

#### Permission Denied
```bash
Error: This script requires root privileges
```
Solution: Use `sudo pipd install `

#### 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:
```bash
sudo pipd -v install
```

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

## 🀝 Contributing

We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

### Development Setup

```bash
# 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](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

- **Issues**: [GitHub Issues](https://github.com/mestadler/pipd/issues)
- **Discussions**: [GitHub Discussions](https://github.com/mestadler/pipd/discussions)
- **Wiki**: [Project Wiki](https://github.com/mestadler/pipd/wiki)

---

Made with ❀️ for the Debian/Ubuntu Python community

## πŸ“š Documentation

- [**Installation Guide**](docs/INSTALL.md) - Detailed installation instructions
- [**User Manual**](docs/MANUAL.md) - Comprehensive usage documentation
- [**PEP 668 Guide**](docs/PEP668.md) - Understanding PEP 668 and how PIPD handles it
- [**Python Compatibility**](docs/PYTHON_COMPATIBILITY.md) - Python version support details
- [**Contributing**](CONTRIBUTING.md) - How to contribute to PIPD

## πŸ“ 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