Skills2026年4月19日·1 分钟阅读

PDM — Modern Python Package and Dependency Manager

PDM is a Python package and dependency manager that supports PEP 582 and PEP 621 standards, offering fast resolution, lockfiles, and build backends without requiring virtualenvs.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
PDM Python Guide
直接安装命令
npx -y tokrepo@latest install 76c003d2-3ba8-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

PDM is a modern Python package manager created by Frost Ming. It follows PEP 621 for project metadata in pyproject.toml and optionally supports PEP 582 for local package installation without virtual environments. PDM provides fast dependency resolution, cross-platform lockfiles, and a flexible build backend system.

What PDM Does

  • Resolves and installs Python dependencies with a fast resolver
  • Generates reproducible cross-platform lockfiles (pdm.lock)
  • Manages virtual environments automatically or uses PEP 582 local packages
  • Supports multiple Python versions and allows switching between them
  • Builds and publishes packages to PyPI with pluggable build backends

Architecture Overview

PDM's resolver uses a backtracking algorithm that evaluates dependency constraints across all transitive packages. It writes a lockfile with pinned versions, hashes, and platform markers. At install time, it reads the lockfile, downloads wheels in parallel, and installs them into either a virtual environment or a __pypackages__ directory (PEP 582). The CLI is plugin-extensible, and the build system delegates to any PEP 517-compatible backend.

Self-Hosting & Configuration

  • Install via pip, pipx, Homebrew, or the official installer script
  • Project configuration uses standard pyproject.toml with [project] and [tool.pdm] sections
  • Python interpreter selection via pdm use or .python-version file
  • Lockfile strategy is configurable: cross-platform (default) or platform-specific
  • CI integration via pdm install --frozen-lockfile for deterministic builds

Key Features

  • PEP 621 compliance: standard [project] table for metadata instead of proprietary formats
  • Dependency groups for dev, test, and optional extras with fine-grained control
  • Script runner (pdm run) with custom script definitions in pyproject.toml
  • Plugin system for extending commands, resolvers, and installers
  • Centralized package cache to save disk space across projects

Comparison with Similar Tools

  • pip — basic installer without lockfiles or resolver guarantees; PDM adds resolution and lockfiles
  • Poetry — similar feature set but uses non-standard [tool.poetry] metadata; PDM follows PEP 621
  • uv — ultra-fast Rust-based installer; PDM is pure Python with a broader feature scope
  • Hatch — focuses on project lifecycle and environments; PDM emphasizes dependency resolution
  • Pipenv — Pipfile-based with slower resolution; PDM is faster and standards-compliant

FAQ

Q: Does PDM require virtual environments? A: No. PDM can use virtual environments (the default) or PEP 582's __pypackages__ directory for project-local installs without virtualenv activation.

Q: Can I migrate from Poetry to PDM? A: Yes. PDM can import pyproject.toml files from Poetry and convert the metadata to PEP 621 format with pdm import.

Q: Does PDM support monorepos? A: Yes. PDM supports workspace-style monorepos with shared lockfiles and cross-project dependencies.

Q: How does PDM handle Python version management? A: PDM detects available Python interpreters and lets you switch with pdm use. It does not install Python versions itself—pair it with pyenv or mise for that.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产