Developer's Cheat Sheet: PDM with kuhl‐haus Packages - kuhl-haus/kuhl-haus-metrics GitHub Wiki
Setup & Installation
Bash
# Install PDM
pip install pdm
# Initialize a new project
pdm init
# Convert existing project
cd existing-project
pdm init
Daily Development (Git References Approach)
Project Configuration (pyproject.toml)
TOML
[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"
[project]
name = "kuhl-haus-bedrock-api"
version = "0.1.0"
dependencies = [
"kuhl-haus-metrics @ git+https://github.com/kuhl-haus/[email protected]",
"kuhl-haus-bedrock-app @ git+https://github.com/kuhl-haus/[email protected]",
]
Common Commands
Bash
# Install dependencies
pdm install
# Update dependencies (respects version constraints)
pdm update
# Add new dependency
pdm add requests
# Add development dependency
pdm add --dev pytest
# Run commands in PDM environment
pdm run pytest
# Build package
pdm build
# Publish package
pdm publish
Cross-Package Development (Workspace Approach)
Setup Workspace
Bash
# Create workspace root
mkdir kuhl-haus-workspace && cd kuhl-haus-workspace
# Create workspace config
cat > pyproject.toml << EOF
[tool.pdm]
[tool.pdm.workspace]
packages = ["kuhl-haus-metrics", "kuhl-haus-canary", "kuhl-haus-bedrock-app", "kuhl-haus-bedrock-api"]
EOF
# Clone repositories
git clone https://github.com/kuhl-haus/kuhl-haus-metrics.git kuhl-haus-metrics
git clone https://github.com/kuhl-haus/kuhl-haus-canary.git kuhl-haus-canary
git clone https://github.com/kuhl-haus/kuhl-haus-bedrock-app.git kuhl-haus-bedrock-app
git clone https://github.com/kuhl-haus/kuhl-haus-bedrock-api.git kuhl-haus-bedrock-api
# Install all dependencies
pdm install
Workspace Commands
Bash
# Run commands across all packages
pdm run -A pytest
# Run command in specific package
pdm run -p bedrock-api pytest
# Update all packages
pdm update --update-all
# Install only dev dependencies
pdm install -d
Testing Changes
Single Package Testing
Bash
# Test current package
pdm run pytest
# Test package with coverage
pdm run pytest --cov=kuhl_haus.metrics --cov-report=html tests -v
# Run with specific arguments
pdm run pytest -xvs tests/
Cross-Package Testing
Bash
# In workspace, test affected packages
pdm run -A pytest
# Test specific package with dependencies
pdm run -p kuhl-haus-bedrock-api pytest
Version Management
Bash
# Update version
pdm bump patch # options: major, minor, patch
# Build release
pdm build
# Publish to PyPI
pdm publish
Quick Reference: Dependency Types
- Regular: pdm add package-name
- Development: pdm add --dev package-name
- Git reference: pdm add "package @ git+https://github.com/org/[email protected]"
- Local path: pdm add "../local-package/"