|
| 1 | +# Installation and Setup Guide |
| 2 | + |
| 3 | +## ✅ Installation Complete! |
| 4 | + |
| 5 | +Your PyDIPLink package has been successfully installed and tested. |
| 6 | + |
| 7 | +## What Was Done |
| 8 | + |
| 9 | +### 1. Virtual Environment Setup |
| 10 | +```bash |
| 11 | +# A fresh virtual environment was created |
| 12 | +python3 -m venv venv |
| 13 | + |
| 14 | +# Activate it (run this command every time you work on the project) |
| 15 | +source venv/bin/activate # On Linux/Mac |
| 16 | +# OR |
| 17 | +venv\Scripts\activate # On Windows |
| 18 | +``` |
| 19 | + |
| 20 | +### 2. Package Installation |
| 21 | +```bash |
| 22 | +# Installed in editable mode with dev dependencies |
| 23 | +pip install -e ".[dev]" |
| 24 | +``` |
| 25 | + |
| 26 | +### 3. Test Results |
| 27 | +✅ **14/14 tests passed!** |
| 28 | +- UART handler: 6/6 tests ✓ |
| 29 | +- Image transfer: 8/8 tests ✓ |
| 30 | +- Code coverage: 43% (core functionality tested) |
| 31 | + |
| 32 | +## Quick Start |
| 33 | + |
| 34 | +### Activate Virtual Environment (IMPORTANT!) |
| 35 | +Every time you open a new terminal, activate the environment: |
| 36 | +```bash |
| 37 | +cd /home/odurgut/book/PyDIPLink |
| 38 | +source venv/bin/activate |
| 39 | +``` |
| 40 | + |
| 41 | +You should see `(venv)` in your prompt: |
| 42 | +``` |
| 43 | +(venv) odurgut@odurgut:~/book/PyDIPLink$ |
| 44 | +``` |
| 45 | + |
| 46 | +### Run the CLI |
| 47 | +```bash |
| 48 | +# Show help |
| 49 | +pydiplink --help |
| 50 | + |
| 51 | +# Run with custom port |
| 52 | +pydiplink --port /dev/ttyUSB0 --baud 500000 |
| 53 | +``` |
| 54 | + |
| 55 | +### Use in Python |
| 56 | +```python |
| 57 | +import pydiplink |
| 58 | + |
| 59 | +print(pydiplink.__version__) # 0.2.0 |
| 60 | + |
| 61 | +# Import functions |
| 62 | +from pydiplink import send_image_data, IMAGE_FORMAT_RGB888 |
| 63 | +``` |
| 64 | + |
| 65 | +## Development Commands |
| 66 | + |
| 67 | +### Run Tests |
| 68 | +```bash |
| 69 | +pytest # Run all tests |
| 70 | +pytest -v # Verbose output |
| 71 | +pytest --cov=pydiplink # With coverage report |
| 72 | +``` |
| 73 | + |
| 74 | +### Code Quality |
| 75 | +```bash |
| 76 | +# Format code |
| 77 | +black pydiplink |
| 78 | + |
| 79 | +# Check imports |
| 80 | +isort pydiplink |
| 81 | + |
| 82 | +# Lint |
| 83 | +flake8 pydiplink |
| 84 | + |
| 85 | +# Type check |
| 86 | +mypy pydiplink |
| 87 | +``` |
| 88 | + |
| 89 | +### Pre-commit Hooks |
| 90 | +```bash |
| 91 | +# Install hooks (one-time) |
| 92 | +pre-commit install |
| 93 | + |
| 94 | +# Run manually |
| 95 | +pre-commit run --all-files |
| 96 | +``` |
| 97 | + |
| 98 | +## Troubleshooting |
| 99 | + |
| 100 | +### "externally-managed-environment" Error |
| 101 | +**Problem:** Trying to install without activating venv |
| 102 | + |
| 103 | +**Solution:** Always activate the virtual environment first: |
| 104 | +```bash |
| 105 | +source venv/bin/activate |
| 106 | +``` |
| 107 | + |
| 108 | +### ImportError |
| 109 | +**Problem:** Package not found |
| 110 | + |
| 111 | +**Solution:** Make sure you're in the activated venv and reinstall: |
| 112 | +```bash |
| 113 | +source venv/bin/activate |
| 114 | +pip install -e ".[dev]" |
| 115 | +``` |
| 116 | + |
| 117 | +### Serial Port Permission Denied |
| 118 | +**Problem:** Can't access `/dev/ttyUSB0` |
| 119 | + |
| 120 | +**Solution:** Add your user to dialout group (Linux): |
| 121 | +```bash |
| 122 | +sudo usermod -a -G dialout $USER |
| 123 | +# Log out and log back in |
| 124 | +``` |
| 125 | + |
| 126 | +## Next Steps |
| 127 | + |
| 128 | +1. **Test with Hardware**: Connect your STM32 and try the examples |
| 129 | + ```bash |
| 130 | + cd examples |
| 131 | + python basic_image_transfer.py |
| 132 | + ``` |
| 133 | + |
| 134 | +2. **Read Documentation**: Check the comprehensive docs |
| 135 | + - [README.md](README.md) - Overview and quick start |
| 136 | + - [docs/API.md](docs/API.md) - Complete API reference |
| 137 | + - [CONTRIBUTING.md](CONTRIBUTING.md) - Development guidelines |
| 138 | + |
| 139 | +3. **Set Up Git**: Prepare for version control |
| 140 | + ```bash |
| 141 | + git add . |
| 142 | + git commit -m "Complete professional refactoring v0.2.0" |
| 143 | + git tag v0.2.0 |
| 144 | + ``` |
| 145 | + |
| 146 | +4. **Publish to PyPI** (when ready): |
| 147 | + ```bash |
| 148 | + python -m build |
| 149 | + twine upload dist/* |
| 150 | + ``` |
| 151 | + |
| 152 | +## Package Structure |
| 153 | + |
| 154 | +``` |
| 155 | +PyDIPLink/ |
| 156 | +├── venv/ # Virtual environment (activated ✓) |
| 157 | +├── pydiplink/ # Main package |
| 158 | +│ ├── __init__.py # v0.2.0 |
| 159 | +│ ├── main.py # CLI |
| 160 | +│ ├── uart_handler.py # UART operations |
| 161 | +│ ├── image_transfer.py # Image send/receive |
| 162 | +│ ├── jpeg_receiver.py # JPEG streaming |
| 163 | +│ └── signal_handler.py # Signal reception |
| 164 | +├── tests/ # Test suite (14 tests ✓) |
| 165 | +├── examples/ # Usage examples |
| 166 | +├── docs/ # Documentation |
| 167 | +├── README.md # 300+ line comprehensive docs |
| 168 | +├── CHANGELOG.md # Version history |
| 169 | +├── LICENSE # MIT License |
| 170 | +└── pyproject.toml # Complete configuration |
| 171 | +``` |
| 172 | + |
| 173 | +## Success Indicators |
| 174 | + |
| 175 | +✅ Virtual environment created and activated |
| 176 | +✅ Package installed in editable mode |
| 177 | +✅ All dependencies installed (production + dev) |
| 178 | +✅ All 14 tests passing |
| 179 | +✅ CLI command working (`pydiplink --help`) |
| 180 | +✅ Python imports working |
| 181 | +✅ Code quality tools ready (black, flake8, mypy, pytest) |
| 182 | + |
| 183 | +--- |
| 184 | + |
| 185 | +**Your PyDIPLink library is ready for development!** 🚀 |
| 186 | + |
| 187 | +For questions or issues, see [CONTRIBUTING.md](CONTRIBUTING.md) or open an issue on GitHub. |
0 commit comments