ppmm 1.1.3

PPM is a project manager for Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
# PPMM - Python Project Manager 

A fast, efficient command-line tool to create, manage, and deploy Python projects. Written in Rust with cross-platform support for Windows, macOS, and Linux.

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Version](https://img.shields.io/badge/version-1.1.3latest-brightgreen.svg)](https://github.com/Sumangal44/ppmm/releases)

## Table of Contents

- [Features]#features
- [Quick Start]#quick-start
- [Installation]#installation
- [Commands]#commands
  - [Create & Initialize Projects]#create--initialize-projects
  - [Package Management]#package-management
  - [Script Management]#script-management
  - [Project Information]#project-information
  - [Requirements Management]#requirements-management
- [Project Configuration]#project-configuration
- [Project Structure]#project-structure
- [Examples]#examples
- [Cross-Platform Support]#cross-platform-support
- [Build From Source]#build-from-source
- [Contributing]#contributing
- [License]#license

## Features

✨ **Core Features:**
- 🗂️ **Project Creation** - Scaffold new Python projects with proper structure
- 📦 **Package Management** - Add, remove, and update Python packages with pip integration
- 🔧 **Virtual Environment Management** - Automatic venv creation and management
- 📝 **Configuration Management** - TOML-based project configuration
- 🚀 **Script Management** - Create and run custom project scripts
- 📋 **Requirements Generation** - Auto-generate requirements.txt from project configuration
- 🔄 **Package Updates** - Update all packages to their latest versions
- 🏷️ **Version Control** - Automatic semantic version bumping (major, minor, patch)
-**Cross-Platform** - Works seamlessly on Windows, macOS, and Linux
-**Performance** - Optimized Rust implementation with zero runtime dependencies

## Quick Start

### Create a New Project

```bash
ppmm new my-project
cd my-project
ppmm start
```

### Initialize in Existing Directory

```bash
cd existing-project
ppmm init
ppmm add numpy pandas
ppmm start
```

### Add Packages

```bash
ppmm add requests flask
ppmm add beautifulsoup4==4.9.0
```

### Run Project

```bash
ppmm start
```

### Run Custom Scripts

```bash
ppmm run test
ppmm run build
```

## Installation

### Script install (Linux/macOS)

From the repository root run:

```bash
git clone https://github.com/Sumangal44/python-project-manager.git
cd python-project-manager
bash install.sh
```

This uses [install.sh](install.sh) to check prerequisites, build, and place `ppm` in `/usr/local/bin` (prompts for sudo if needed).

### Quick one-liner (Linux/macOS)

```bash
bash <(curl -s https://raw.githubusercontent.com/Sumangal44/python-project-manager/master/quick-install.sh)
```

Or run locally: `bash quick-install.sh` after cloning. Script lives at [quick-install.sh](quick-install.sh).

### Manual install (Linux/macOS/Windows)

Requirements: Rust 1.60+, Python 3.7+, Git.

```bash
git clone https://github.com/Sumangal44/python-project-manager.git
cd python-project-manager
cargo build --release

# Linux/macOS
sudo cp target/release/ppmm /usr/local/bin/

# Windows (PowerShell/CMD)
copy target\release\ppm.exe C:\\Windows\\System32\\   # or add target\release to PATH

ppmm --version
```

Binary output: `target/release/ppmm` (or `ppm.exe` on Windows).

## Commands

### Create & Initialize Projects

#### `ppmm new <NAME>`
Create a new Python project with scaffolding.

**Options:**
- `-v, --version <VERSION>` - Project version (default: `0.1.0`)
- `-d, --description <DESC>` - Project description
- `-g, --git` - Initialize git repository
- `-e, --no-venv` - Skip virtual environment creation

**Examples:**
```bash
# Create basic project
ppmm new my-project

# Create with metadata and git
ppmm new my-project -v 1.0.0 -d "My awesome project" -g

# Create without venv
ppmm new my-project --no-venv
```

#### `ppmm init`
Initialize a Python project in the current directory.

**Options:**
- Same as `ppmm new`

**Examples:**
```bash
# Initialize in current directory
ppmm init

# Initialize with git
ppmm init -g
```

### Package Management

#### `ppmm add <PACKAGES>`
Add one or more packages to the project.

**Features:**
- Installs to virtual environment automatically
- Supports version pinning (e.g., `package==1.2.3`)
- Updates `project.toml` automatically
- Validates package names

**Examples:**
```bash
# Add multiple packages
ppmm add requests flask numpy

# Add specific versions
ppmm add django==3.2.0 pillow==9.0.0

# Mix and match
ppmm add requests flask==2.0.0 numpy
```

#### `ppmm rm <PACKAGES>`
Remove packages from the project and environment.

**Features:**
- Removes from virtual environment
- Updates `project.toml`
- Validates package existence

**Examples:**
```bash
ppmm rm requests
ppmm rm flask numpy pandas
```

#### `ppmm update`
Update all packages to their latest versions from PyPI.

**Features:**
- Fetches latest versions from PyPI API
- Updates all packages atomically
- Reports failed updates

**Examples:**
```bash
ppmm update
```

### Script Management

#### `ppmm run <SCRIPT-NAME>`
Execute a custom script defined in `project.toml`.

**Features:**
- Cross-platform command execution
- Access to virtual environment
- Real-time output streaming

**Examples:**
```bash
ppmm run test
ppmm run build
ppmm run dev
```

#### `ppmm build`
Run the `build` script defined in the `[scripts]` section of `project.toml`.

**Features:**
- Uses the project's virtual environment on PATH
- Cross-platform execution (`cmd` on Windows, `sh -c` on Linux/macOS)
- Warns if `scripts.build` is not defined

**Examples:**
```bash
# Ensure project.toml contains:
# [scripts]
# build = "python setup.py build"

ppmm build
```

#### `ppmm bump <TYPE>`
Automatically bump the project version following semantic versioning.

**Arguments:**
- `major` - Increment major version (1.0.0 → 2.0.0)
- `minor` - Increment minor version (1.0.0 → 1.1.0)
- `patch` - Increment patch version (1.0.0 → 1.0.1)

**Features:**
- Parses semantic versions (major.minor.patch)
- Strips alpha/beta suffixes before bumping
- Updates project.toml automatically
- Shows colored version bump info

**Examples:**
```bash
# Bump patch version
ppmm bump patch

# Bump minor version
ppmm bump minor

# Bump major version
ppmm bump major
```

### Project Information

#### `ppmm info`
Display comprehensive project information.

**Shows:**
- Project name, version, description
- Python version in use
- All configured scripts
- All installed packages (up to 10 with count)

**Example Output:**
```
Python: 3.9.0

Project: my-project
Version: 1.0.0
Description: An awesome project

-- 4 Scripts --
test: python -m pytest tests/
build: python setup.py build
dev: python -m flask run
upgrade: python -m pip install --upgrade pip

-- 5 Packages --
flask==2.1.0
numpy==1.21.0
pandas==1.3.0
requests==2.26.0
pytest==6.2.0

```

### Requirements Management

#### `ppmm gen`
Generate a `requirements.txt` file from `project.toml`.

**Features:**
- Extracts all packages and versions
- Creates standard requirements.txt format
- Overwrites existing requirements.txt

**Examples:**
```bash
ppmm gen

# Equivalent to: pip freeze > requirements.txt
```

#### `ppmm install`
Install all packages from `project.toml`.

**Features:**
- Creates venv if missing
- Batch installs all packages
- Validates all packages exist

**Options:**
- `-r, --requirements <FILE>` - Install from requirements.txt instead

**Examples:**
```bash
# Install from project.toml
ppmm install

# Install from requirements.txt
ppmm install -r requirements.txt
ppmm install --requirements /path/to/reqs.txt
```

## Project Configuration

### `project.toml` Format

PPM uses TOML for project configuration. Here's the complete format:

```toml
[project]
name = "my-project"
version = "1.0.0"
description = "An awesome Python project"
main_script = "./src/main.py"

[packages]
# Production dependencies
requests = "2.28.0"
flask = "2.1.0"
numpy = "1.21.0"

[scripts]
# Custom scripts
test = "python -m pytest tests/ -v"
lint = "python -m pylint src/"
format = "python -m black src/"
build = "python setup.py build"
dev = "python -m flask run --debug"
upgrade-pip = "python -m pip install --upgrade pip"
```

### Configuration Details

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `project.name` | String | Yes | Project name |
| `project.version` | String | Yes | Project version (semver) |
| `project.description` | String | No | Project description |
| `project.main_script` | String | Yes | Entry point script |
| `packages.<name>` | String | No | Package with version |
| `scripts.<name>` | String | No | Command to execute |

## Project Structure

PPM creates the following structure for new projects:

```
my-project/
├── project.toml          # Project configuration
├── requirements.txt      # Auto-generated dependencies
├── venv/                 # Virtual environment
│   ├── bin/             # Executables (Linux/macOS)
│   ├── Scripts/         # Executables (Windows)
│   └── lib/             # Installed packages
├── src/
│   └── main.py          # Entry point
└── .gitignore           # Git ignore (if -g flag used)
```

## Examples

### Example 1: Web API Project

```bash
# Create project
ppmm new api-server -v 1.0.0 -d "REST API server" -g

# Add dependencies
ppmm add flask flask-cors flask-sqlalchemy

# Create scripts
# Edit project.toml to add:
# [scripts]
# dev = "python -m flask run"
# prod = "gunicorn main:app"

# Start development
ppmm start
```

### Example 2: Data Science Project

```bash
# Create project
ppmm new data-analysis -d "Data analysis project"

# Add data science packages
ppmm add pandas numpy scipy matplotlib scikit-learn jupyter

# Generate requirements for sharing
ppmm gen

# Update all packages
ppmm update
```

### Example 3: Migrate from pip

```bash
# Convert existing project
cd my-existing-project
ppmm init -g

# Install from existing requirements
ppmm install -r requirements.txt

# Generate new project config
ppmm gen
```

## Cross-Platform Support

PPM is fully cross-platform and tested on:

- **Windows** - Full support, `.exe` extensions handled automatically
- **macOS** - Full support, uses `bin/` for venv
- **Linux** - Full support, uses `bin/` for venv

The tool automatically detects your platform and uses the correct paths and commands.

### Platform-Specific Paths

| Platform | Python Path | Pip Path |
|----------|-------------|----------|
| Windows | `./venv/Scripts/python.exe` | `./venv/Scripts/pip.exe` |
| Linux/macOS | `./venv/bin/python` | `./venv/bin/pip` |

## Build From Source

### Prerequisites

```bash
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Install Python 3.7+
# From: https://www.python.org/downloads/
```

### Building

```bash
git clone https://github.com/Sumangal44/python-project-manager
cd python-project-manager

# Build debug version
cargo build

# Build optimized release version
cargo build --release

# Run tests
cargo test

# Run clippy linter
cargo clippy
```

### Output

Binary location: `target/release/ppmm` (or `ppm.exe` on Windows)

### Development

```bash
# Run directly from source
cargo run -- new my-project

# Debug mode with verbose output
RUST_LOG=debug cargo run -- new my-project

# Watch mode (requires cargo-watch)
cargo watch -x build
```

## Requirements

### Runtime

- Python 3.7 or newer
- pip (comes with Python)

### Development

- Rust 1.60 or newer
- Cargo (comes with Rust)
- Git (for version control)

## Features Status

### ✅ Implemented

- Project scaffolding with automatic structure
- Virtual environment management
- Package installation/removal
- Package update checking from PyPI
- Script execution
- Requirements.txt generation
- Cross-platform support (Windows, macOS, Linux)
- TOML configuration
- Git integration (optional)
- Error handling and validation
- Package name validation
- Improved error messages
- Cross-platform path handling

### 🚀 Planned Features

- Dependency resolution
- Lock file support (like Cargo.lock)
- Dev dependencies separation
- Python version management
- Project templates
- Virtual environment isolation validation
- Package conflict detection
- Installation progress bar
- Caching of PyPI responses

## Troubleshooting

### Virtual Environment Not Found

**Problem:** "Virtual Environment Not Found"

**Solutions:**
1. Create venv: `ppmm new my-project` (auto-creates)
2. Manually create: `python -m venv venv`
3. Use `--no-venv` flag if intentional

### Package Installation Failed

**Problem:** "Package 'X' failed to install"

**Solutions:**
1. Check package name spelling
2. Verify package exists: `pip search <package>`
3. Check pip version: `pip --version`
4. Update pip: `ppmm run upgrade-pip`

### Python Not Found

**Problem:** "python command not found"

**Solutions:**
1. Ensure Python is installed
2. Add Python to PATH
3. Use absolute path in scripts

### Cross-Platform Issues

**Windows:**
- Use forward slashes in `project.toml` (scripts: `"python -m pytest tests/"`)
- Paths are normalized automatically

**Linux/macOS:**
- Ensure execute permissions: `chmod +x venv/bin/python`

## Contributing

Contributions are welcome! Please:

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit changes (`git commit -m 'Add amazing feature'`)
4. Push to branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

### Development Guidelines

- Follow Rust conventions (rustfmt)
- Pass clippy linter checks
- Add tests for new features
- Update documentation

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Author

**sumangal44** - Original Creator

Based on the PPM concept for streamlined Python project management.

## Acknowledgments

- Built with [Rust]https://www.rust-lang.org/
- Uses [Clap]https://docs.rs/clap for CLI parsing
- Uses [TOML]https://docs.rs/toml for configuration
- Uses [Reqwest]https://docs.rs/reqwest for PyPI API
- Uses [Colored]https://docs.rs/colored for terminal colors

## Support

For issues, questions, or suggestions:

- Open an [Issue]https://github.com/Sumangal44/python-project-manager/issues
- Check [Discussions]https://github.com/Sumangal44/python-project-manager/discussions
- Read the [Wiki]https://github.com/Sumangal44/python-project-manager/wiki

## Changelog

### Version 1.1.0

- ✅ Added `ppmm build` command for project builds
- ✅ Added `ppmm bump` command for semantic versioning (major, minor, patch)
- ✅ Automatic version control and management
- ✅ Install script with prerequisites checking
- ✅ Quick one-liner installer support
- ✅ Updated documentation and examples

### Version 1.0.0-alpha

- ✅ Initial release
- ✅ Cross-platform support
- ✅ Package management
- ✅ Virtual environment management
- ✅ Script execution
- ✅ Requirements generation
- ✅ Improved error handling
- ✅ TOML configuration
- ✅ Optimized Rust codebase
- ✅ Zero clippy warnings
- ✅ Production-ready

---

**Made with ❤️ in Rust**