This guide covers the modernization of shconfparser from version 2.x to 3.0 with modern Python tooling.
We've migrated from traditional setup.py to modern pyproject.toml and adopted uv as the recommended package manager.
- 10-100x faster than pip
- Better dependency resolution
- Built-in virtual environment management
- Single tool for all Python package operations
- ✅ Supported: Python 3.8, 3.9, 3.10, 3.11, 3.12, 3.13
- ❌ Dropped: Python 2.7, 3.1-3.7
| Tool | Purpose | Configuration |
|---|---|---|
| uv | Package manager | pyproject.toml |
| ruff | Fast linter (replaces flake8) | pyproject.toml |
| black | Code formatter | pyproject.toml |
| mypy | Type checker | pyproject.toml |
| pytest | Testing framework | pyproject.toml |
| pre-commit | Git hooks | .pre-commit-config.yaml |
pip install shconfparser# Install uv first
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install shconfparser
uv pip install shconfparsergit clone https://github.com/network-tools/shconfparser.git
cd shconfparsercurl -LsSf https://astral.sh/uv/install.sh | sh# Create virtual environment and install dependencies
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install package in editable mode with dev dependencies
uv pip install -e . --devuv pip install pre-commit
pre-commit installWe provide a comprehensive Makefile for common tasks:
# Install the package
make install
# Install with dev dependencies
make dev-install
# Run tests with coverage
make test
# Lint code
make lint
# Format code
make format
# Type check
make type-check
# Run all checks
make check-all
# Clean build artifacts
make clean
# Build distribution packages
make build
# Publish to PyPI
make publish# Run all tests
uv run pytest
# Run with coverage
uv run pytest --cov=shconfparser
# Run specific test file
uv run pytest tests/test_parser.py# Format code
uv run black .
# Lint code
uv run ruff check .
# Auto-fix linting issues
uv run ruff check --fix .
# Type check
uv run mypy shconfparserThe API remains backward compatible. Your existing code will continue to work:
from shconfparser.parser import Parser
p = Parser()
data = p.read('config.txt')
# ... rest of your code# setup.py based
pip install -r requirements_dev.txt
pip install -e .
python setup.py test# pyproject.toml + uv based
uv pip install -e . --dev
make test
# or
uv run pytestWe now use modern GitHub Actions with uv:
-
Test workflow:
.github/workflows/test-uv.yml- Tests on Python 3.8-3.13
- Runs on Ubuntu, macOS, Windows
- Uploads coverage to Codecov
-
Publish workflow:
.github/workflows/publish-uv.yml- Builds with uv
- Publishes to PyPI on release
- Old pytest workflows
- tox.ini (replaced by uv matrix testing)
- requirements*.txt (now in pyproject.toml)
- Pipfile (replaced by uv)
shconfparser/
├── pyproject.toml # ✨ New: All configuration in one place
├── Makefile # ✨ New: Easy development commands
├── .pre-commit-config.yaml # ✨ New: Pre-commit hooks
├── .github/workflows/
│ ├── test-uv.yml # ✨ New: Modern CI with uv
│ └── publish-uv.yml # ✨ New: Publishing with uv
├── shconfparser/
│ ├── __init__.py # ✨ Updated: Modern logging, type hints
│ ├── py.typed # ✨ New: Type information
│ └── ...
├── setup_old.py # 📦 Archived: Old setup.py
└── ...
✅ Implemented:
- PEP 8 compliance via black and ruff
- Type hints for better IDE support
- 100% test coverage target
- Security scanning via CodeQL
- Automated formatting in CI/CD
- Pre-commit hooks for quality gates
✅ Implemented:
- Comprehensive README with examples
- API documentation in docstrings
- CHANGELOG for version tracking
- CONTRIBUTING guidelines
- CODE_OF_CONDUCT for community
✅ Implemented:
- Semantic versioning (MAJOR.MINOR.PATCH)
- Automated testing before release
- GitHub releases with changelog
- PyPI trusted publishing
- Artifact signing
✅ Implemented:
- CodeQL analysis in CI
- Dependabot for dependency updates
- Security policy (SECURITY.md)
- Regular dependency audits
Problem: uv: command not found
Solution:
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Add to PATH (if not automatic)
export PATH="$HOME/.cargo/bin:$PATH"Problem: ModuleNotFoundError: No module named 'shconfparser'
Solution:
# Make sure you're in the virtual environment
source .venv/bin/activate
# Reinstall in editable mode
uv pip install -e .Problem: Tests fail with import errors
Solution:
# Clean and reinstall
make clean
make dev-install
make test- uv Documentation: https://docs.astral.sh/uv/
- ruff Documentation: https://docs.astral.sh/ruff/
- Python Packaging Guide: https://packaging.python.org/
- pyproject.toml Reference: https://peps.python.org/pep-0621/
- Report issues: https://github.com/network-tools/shconfparser/issues
- Ask questions: https://stackoverflow.com (tag: shconfparser)
- Email: kirankotari@live.com
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Made with ❤️ by the shconfparser team