IPECMD Wrapper Development¶
This directory contains the IPECMD Wrapper package development environment with modern tooling.
Quick Start¶
# Install in development mode
pip install -e .
# Install with development dependencies
pip install -e .[dev]
# Run tests
pytest
# Run tests with coverage
pytest --cov=ipecmd_wrapper
# Format and lint code (modern unified tooling)
ruff format .
ruff check .
# Type checking
mypy .
# Build package
python -m build
Modern Development Stack¶
This project uses modern Python development tools:
- π¨ Ruff: Unified formatter and linter (replaces black + flake8 + isort)
- π― Typer: Modern CLI framework with rich formatting and validation
- β pytest: Comprehensive testing framework
- π mypy: Static type checking
- π¦ build: Modern package building
- π pre-commit: Git hooks for code quality
Package Structure¶
ipecmd_wrapper/
βββ pyproject.toml # Modern Python package configuration
βββ README.md # Package documentation
βββ LICENSE # MIT license
βββ .gitignore # Git ignore rules
βββ ipecmd_wrapper/ # Main package directory
β βββ __init__.py # Package initialization
β βββ cli.py # Modern Typer CLI with validation
β βββ core.py # Core functionality
βββ tests/ # Comprehensive test suite
βββ __init__.py
βββ test_cli.py # Typer CLI tests
βββ test_core.py
βββ test_integration.py
βββ test_performance.py
βββ test_compatibility.py
Usage¶
After installation, you can use the wrapper as:
# Command-line tool
ipecmd-wrapper PIC16F876A PK3 --file firmware.hex --power 5.0
# Python module
python -m ipecmd_wrapper.cli PIC16F876A PK3 --file firmware.hex --power 5.0
# Python API
from ipecmd_wrapper import get_ipecmd_path, upload_firmware
Development Commands¶
Setup Development Environment¶
# Automated setup (recommended)
python setup_dev.py
# Manual setup
python -m venv .venv
source .venv/bin/activate # Unix/macOS
.venv\Scripts\activate # Windows
pip install -e .[dev]
pre-commit install
Testing¶
# Run all tests
pytest
# Run tests with coverage
pytest --cov=ipecmd_wrapper --cov-report=html
# Run specific test categories
pytest -m unit # Unit tests only
pytest -m integration # Integration tests only
pytest -m performance # Performance tests only
pytest -m compatibility # Compatibility tests only
# Run tests in parallel
pytest -n auto
# Run specific test file
pytest tests/test_core.py
Code Quality¶
# Format code
black .
# Format and lint code (replaces black, isort, flake8)
ruff check --fix .
ruff format .
# Type checking
mypy .
# Security scanning
bandit -r ipecmd_wrapper/
# Run all pre-commit hooks
pre-commit run --all-files
Build and Release¶
# Build package
python -m build
# Upload to PyPI (maintainers only)
twine upload dist/*
# Create release
git tag v0.1.0
git push origin v0.1.0
Testing Strategy¶
Test Categories¶
- Unit Tests: Test individual functions and classes in isolation
- Integration Tests: Test component interactions and workflows
- Performance Tests: Benchmark critical operations
- Compatibility Tests: Test across different platforms and Python versions
Test Organization¶
test_cli.py
: Command-line interface teststest_core.py
: Core functionality teststest_integration.py
: Integration and workflow teststest_performance.py
: Performance and benchmarking teststest_compatibility.py
: Cross-platform compatibility tests
Running Tests¶
# Quick test run (exclude slow tests)
pytest -m "not slow"
# Full test suite
pytest
# Coverage report
pytest --cov=ipecmd_wrapper --cov-report=html
open htmlcov/index.html # View coverage report
Code Style¶
We follow PEP 8 with these conventions:
- Line length: 88 characters (Black default)
- Use double quotes for strings
- Use type hints for all public functions
- Document public APIs with docstrings
- Use Google-style docstrings
Continuous Integration¶
The project uses GitHub Actions for CI/CD:
- Tests: Run on Windows, Linux, and macOS
- Python versions: 3.9, 3.10, 3.11, 3.12
- Code quality: Linting, formatting, type checking
- Coverage: Minimum 80% code coverage
- Security: Vulnerability scanning
Release Process¶
- Update version in
pyproject.toml
- Update
docs/changelog.md
- Create and push git tag
- GitHub Actions automatically builds and publishes to PyPI
- Update documentation
Contributing¶
See contributing.md for detailed contribution guidelines.
License¶
This project is licensed under the MIT License - see the LICENSE file for details.