This file provides guidance to AI coding assistants when working with code in this repository.
PDM (Python Dependency Manager) is a modern Python package and dependency manager that supports the latest PEP standards (PEP 517, PEP 621). It provides fast dependency resolution, flexible plugin system, and centralized cache management similar to pnpm.
- Project Management (
src/pdm/project/): Handles pyproject.toml parsing, project configuration, and metadata management - Dependency Resolution (
src/pdm/resolver/): Fast dependency resolver using resolvelib with custom optimizations for binary distributions - Environment Management (
src/pdm/environments/): Manages Python environments (virtualenv, PEP 582, system) - Installer System (
src/pdm/installers/): Installs and uninstalls packages into the site-packages directory with centralized cache support - CLI System (
src/pdm/cli/commands/): Command-line interface using argparse with plugin support - Repository Models (
src/pdm/models/repositories/): PyPI repository interaction and package finder - Build System (
src/pdm/builders/): PEP 517 build front-end for creating wheels and sdists
All CLI commands are in src/pdm/cli/commands/ with command registration in src/pdm/core.py. Commands inherit from BaseCommand and use decorator patterns for common options.
# Install development dependencies
pdm install# Run all tests
pdm run test
# Run tests in parallel
pdm run test -n autoMost of the time, you can exclude tests with "integration" mark to save runtime:
pdm run test -n auto -m "not integration"# Run linting (ruff-format + codespell + mypy)
pdm run lint# Serve documentation locally
pdm run docRefer to CONTRIBUTING.md
pyproject.toml: Project configuration and dependenciessrc/pdm/core.py: Main application entry point and command registrationsrc/pdm/project/__init__.py: Project class managing project statesrc/pdm/cli/commands/base.py: Base command class for all CLI commands.pre-commit-config.yaml: Code quality hooks (ruff, mypy, codespell)
- Create new file in
src/pdm/cli/commands/ - Inherit from
BaseCommand - Register in
src/pdm/core.py
- Set
PDM_DEBUG=1environment variable for verbose output - Check
pdm.lockfor resolved versions - Use
pdm lock --checkto verify lock file
PDM uses its own lock file format (pdm.lock) that includes:
- Exact versions with hashes
- Environment markers
- Cross-platform support
- Group dependencies
# Add a new dependency to default group
pdm add <package_name>
# Update all dependencies
pdm update
# Remove a dependency
pdm remove <package_name>
# Add a new dependency to given group
pdm add <package_name> --group <group_name>- Dependency Injection: Core class passed to commands
- Signal System: Event-driven architecture for plugins
- Repository Pattern: Abstract repository interface for package sources
- Strategy Pattern: Different environment backends (venv, conda, etc.)
- Chain of Responsibility: Middleware system for HTTP client