|
| 1 | +# pyp - C++ Virtual Environment Manager |
| 2 | + |
| 3 | +<p align="center"> |
| 4 | + <img src="https://img.shields.io/badge/C%2B%2B-17-blue.svg" alt="C++17"> |
| 5 | + <img src="https://img.shields.io/badge/Version-2.0.0-green.svg" alt="Version"> |
| 6 | + <img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License"> |
| 7 | + <img src="https://img.shields.io/badge/Platforms-Linux%20%7C%20macOS%20%7C-Windows-lightgrey.svg" alt="Platforms"> |
| 8 | +</p> |
| 9 | + |
| 10 | +<p align="center"> |
| 11 | + <strong>A lightweight, high-performance Python virtual environment manager built in C++</strong> |
| 12 | +</p> |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## 🌟 Features |
| 17 | + |
| 18 | +- **Blazing Fast** - Written in C++ for instant startup and minimal memory usage |
| 19 | +- **Zero Dependencies** - Built with only standard C++ libraries (no external dependencies) |
| 20 | +- **Cross-Platform** - Works on Linux, macOS, and Windows |
| 21 | +- **Beautiful Output** - Colorized terminal output for better readability |
| 22 | +- **User-Friendly** - Simple, intuitive commands |
| 23 | +- **Secure** - No Python runtime vulnerabilities, smaller attack surface |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +## 🚀 Quick Start |
| 28 | + |
| 29 | +### Installation |
| 30 | + |
| 31 | +```bash |
| 32 | +# Clone or download the source |
| 33 | +cd pyp-cpp |
| 34 | + |
| 35 | +# Make install script executable |
| 36 | +chmod +x install.sh |
| 37 | + |
| 38 | +# Run installation |
| 39 | +./install.sh |
| 40 | + |
| 41 | +# Restart your shell or source your config |
| 42 | +source ~/.bashrc # or ~/.zshrc |
| 43 | + |
| 44 | +# Verify installation |
| 45 | +pyp --help |
| 46 | +``` |
| 47 | + |
| 48 | +### Basic Usage |
| 49 | + |
| 50 | +```bash |
| 51 | +# Create a virtual environment |
| 52 | +pyp -b myenv |
| 53 | + |
| 54 | +# Create with specific Python version |
| 55 | +pyp -b myenv --python 3.11 |
| 56 | + |
| 57 | +# Create with system site-packages |
| 58 | +pyp -b myenv --system-site-packages |
| 59 | + |
| 60 | +# Create and upgrade pip/setuptools |
| 61 | +pyp -b myenv --upgrade |
| 62 | + |
| 63 | +# Activate environment |
| 64 | +pyp -a myenv |
| 65 | + |
| 66 | +# List all environments |
| 67 | +pyp -l |
| 68 | + |
| 69 | +# Show environment info |
| 70 | +pyp -i myenv |
| 71 | + |
| 72 | +# Set default environment |
| 73 | +pyp --set-default myenv |
| 74 | + |
| 75 | +# Deactivate (run in shell) |
| 76 | +deactivate |
| 77 | + |
| 78 | +# Remove environment |
| 79 | +pyp --remove myenv |
| 80 | +``` |
| 81 | + |
| 82 | +--- |
| 83 | + |
| 84 | +## 📋 Command Reference |
| 85 | + |
| 86 | +| Command | Description | |
| 87 | +|---------|-------------| |
| 88 | +| `pyp -b <name>` | Create a new virtual environment | |
| 89 | +| `pyp -a <name>` | Activate a virtual environment | |
| 90 | +| `pyp -d` | Deactivate current environment | |
| 91 | +| `pyp -l` | List all environments | |
| 92 | +| `pyp -i <name>` | Show environment information | |
| 93 | +| `pyp --set-default <name>` | Set default environment | |
| 94 | +| `pyp --remove <name>` | Remove an environment | |
| 95 | +| `pyp --help` | Show help message | |
| 96 | +| `pyp --version` | Show version information | |
| 97 | + |
| 98 | +### Options |
| 99 | + |
| 100 | +| Option | Description | |
| 101 | +|--------|-------------| |
| 102 | +| `--python VERSION` | Python version (e.g., `3.11`) | |
| 103 | +| `--system-site-packages` | Include system site-packages | |
| 104 | +| `--upgrade` | Upgrade pip and setuptools after creation | |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +## 🏗️ Installation Options |
| 109 | + |
| 110 | +### Default Installation |
| 111 | + |
| 112 | +```bash |
| 113 | +./install.sh |
| 114 | +``` |
| 115 | + |
| 116 | +- Installs to `~/.local/bin` |
| 117 | +- Automatically configures PATH |
| 118 | +- Creates backup of existing configuration |
| 119 | + |
| 120 | +### Custom Installation Directory |
| 121 | + |
| 122 | +```bash |
| 123 | +./install.sh --install-dir /usr/local/bin |
| 124 | +``` |
| 125 | + |
| 126 | +### Skip PATH Configuration |
| 127 | + |
| 128 | +```bash |
| 129 | +./install.sh --no-path |
| 130 | +``` |
| 131 | + |
| 132 | +### Force Reinstallation |
| 133 | + |
| 134 | +```bash |
| 135 | +./install.sh --force |
| 136 | +``` |
| 137 | + |
| 138 | +--- |
| 139 | + |
| 140 | +## 🗑️ Uninstallation |
| 141 | + |
| 142 | +### Standard Uninstallation |
| 143 | + |
| 144 | +```bash |
| 145 | +./uninstall.sh |
| 146 | +``` |
| 147 | + |
| 148 | +### Keep Configuration |
| 149 | + |
| 150 | +```bash |
| 151 | +./uninstall.sh --keep-config |
| 152 | +``` |
| 153 | + |
| 154 | +### Skip Confirmation |
| 155 | + |
| 156 | +```bash |
| 157 | +./uninstall.sh --force |
| 158 | +``` |
| 159 | + |
| 160 | +--- |
| 161 | + |
| 162 | +## 🔧 Technical Details |
| 163 | + |
| 164 | +### Compilation Requirements |
| 165 | + |
| 166 | +- **Compiler**: g++ or clang++ |
| 167 | +- **Standard**: C++17 (for `<filesystem>` support) |
| 168 | +- **Flags**: `-std=c++17 -O2 -Wall -Wextra` |
| 169 | + |
| 170 | +### Built-in Libraries Used |
| 171 | + |
| 172 | +```cpp |
| 173 | +#include <iostream> // Input/output streams |
| 174 | +#include <fstream> // File operations |
| 175 | +#include <sstream> // String streams |
| 176 | +#include <string> // String manipulation |
| 177 | +#include <vector> // Dynamic arrays |
| 178 | +#include <map> // Key-value pairs |
| 179 | +#include <filesystem> // File system operations (C++17) |
| 180 | +#include <cstdlib> // System calls |
| 181 | +#include <chrono> // Time operations |
| 182 | +``` |
| 183 | + |
| 184 | +### Performance Comparison |
| 185 | + |
| 186 | +| Metric | Python Version | C++ Version | |
| 187 | +|--------|---------------|-------------| |
| 188 | +| Startup Time | ~50-100ms | ~1-5ms | |
| 189 | +| Memory Usage | ~10-20MB | ~1-5MB | |
| 190 | +| Dependencies | Python 3.6+ | None | |
| 191 | + |
| 192 | +--- |
| 193 | + |
| 194 | +## 📁 Project Structure |
| 195 | + |
| 196 | +``` |
| 197 | +pyp-cpp/ |
| 198 | +├── main.cpp # Main C++ source code |
| 199 | +├── install.sh # Installation script |
| 200 | +├── uninstall.sh # Uninstallation script |
| 201 | +├── test.sh # Test script |
| 202 | +├── README.md # This file |
| 203 | +└── LICENSE # MIT License |
| 204 | +``` |
| 205 | + |
| 206 | +--- |
| 207 | + |
| 208 | +## 🐧 Platform-Specific Notes |
| 209 | + |
| 210 | +### Linux |
| 211 | + |
| 212 | +- Default install directory: `~/.local/bin` |
| 213 | +- Requires `g++` or `clang++` |
| 214 | +- Supports bash and zsh |
| 215 | + |
| 216 | +### macOS |
| 217 | + |
| 218 | +- Requires Xcode command line tools |
| 219 | +- Supports zsh (default shell on macOS 10.15+) |
| 220 | +- Uses BSD sed instead of GNU sed |
| 221 | + |
| 222 | +### Windows |
| 223 | + |
| 224 | +- Uses WSL or MinGW for compilation |
| 225 | +- Supports PowerShell and CMD |
| 226 | +- Binary: `pyp.exe` |
| 227 | + |
| 228 | +--- |
| 229 | + |
| 230 | +## 📝 Configuration |
| 231 | + |
| 232 | +### Configuration File |
| 233 | + |
| 234 | +Location: `~/.pyp_config.json` |
| 235 | + |
| 236 | +```json |
| 237 | +{ |
| 238 | + "myenv": { |
| 239 | + "path": "/home/user/projects/myenv", |
| 240 | + "python": "/usr/bin/python3", |
| 241 | + "created": "2024-01-01 12:00:00" |
| 242 | + }, |
| 243 | + "default": { |
| 244 | + "path": "/home/user/projects/myenv", |
| 245 | + "python": "/usr/bin/python3" |
| 246 | + } |
| 247 | +} |
| 248 | +``` |
| 249 | + |
| 250 | +--- |
| 251 | + |
| 252 | +## 🤝 Contributing |
| 253 | + |
| 254 | +1. Fork the repository |
| 255 | +2. Create your feature branch (`git checkout -b feature/amazing-feature`) |
| 256 | +3. Commit your changes (`git commit -m 'Add amazing feature'`) |
| 257 | +4. Push to the branch (`git push origin feature/amazing-feature`) |
| 258 | +5. Open a Pull Request |
| 259 | + |
| 260 | +--- |
| 261 | + |
| 262 | +## 📄 License |
| 263 | + |
| 264 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 265 | + |
| 266 | +--- |
| 267 | + |
| 268 | +## 🙏 Acknowledgments |
| 269 | + |
| 270 | +- Inspired by [mosi-sol/idea-factory/pyp-Secure_python_venv](https://github.com/mosi-sol/idea-factory/tree/main/pyp-Secure_python_venv) - **same creator** |
| 271 | +- Python Software Foundation for the venv module |
| 272 | +- C++ community for the excellent standard library |
| 273 | + |
| 274 | +--- |
| 275 | + |
| 276 | +<p align="center"> |
| 277 | + LotusOS-Core , 2025-2026 |
| 278 | +</p> |
0 commit comments