Introduction#
PDM, as described, is a modern Python package and dependency manager supporting the latest PEP standards. But it is more than a package manager. It boosts your development workflow in various aspects.
Feature highlights#
- Simple and fast dependency resolver, mainly for large binary distributions.
- A PEP 517 build backend.
- PEP 621 project metadata.
- Flexible and powerful plug-in system.
- Versatile user scripts.
- Install Pythons using indygreg's python-build-standalone.
- Opt-in centralized installation cache like pnpm.
Installation#
PDM requires Python 3.9+ to be installed. It works on multiple platforms including Windows, Linux and macOS.
Note
You can still have your project working on lower Python versions, read how to do it here.
Recommended installation method#
PDM requires python version 3.9 or higher.
Like Pip, PDM provides an installation script that will install PDM into an isolated environment.
1 |
|
1 |
|
Note
On Windows, if you do not have the optional py
launcher installed (including if you installed Python through the Microsoft store), replace py
with python
.
For security reasons, you should verify the checksum of install-pdm.py
.
It can be downloaded from install-pdm.py.sha256.
For example, on Linux/Mac:
1 2 3 4 |
|
The installer will install PDM into the user site and the location depends on the system:
$HOME/.local/bin
for Unix$HOME/Library/Python/<version>/bin
for MacOS%APPDATA%\Python\Scripts
on Windows
You can pass additional options to the script to control how PDM is installed:
1 2 3 4 5 6 7 8 9 10 |
|
You can either pass the options after the script or set the env var value.
Other installation methods#
1 |
|
1 2 |
|
1 |
|
1 |
|
Install the head version of GitHub repository. Make sure you have installed Git LFS on your system.
1 |
|
To install PDM with all features:
1 |
|
See also: https://pypa.github.io/pipx/
1 |
|
Assuming you have asdf installed.
1 2 3 |
|
By copying the Pyprojectx wrapper scripts to a project, you can install PDM as (npm-style) dev dependency inside that project. This allows different projects/branches to use different PDM versions.
To initialize a new or existing project, cd into the project folder and:
1 2 |
|
1 2 |
|
When installing pdm with this method, you need to run all pdm
commands through the pw
wrapper:
1 |
|
Update the PDM version#
1 |
|
Uninstallation#
If you need to remove PDM from your system, you can use the following script:
1 |
|
1 |
|
If you installed PDM using a third-party package management tool like Homebrew, you can also uninstall PDM using the tool's uninstall method, such as brew uninstall pdm
.
Packaging Status#
Shell Completion#
PDM supports generating completion scripts for Bash, Zsh, Fish or Powershell. Here are some common locations for each shell:
1 2 |
|
1 2 |
|
Oh-My-Zsh:
1 2 |
|
Then make sure pdm plugin is enabled in ~/.zshrc
1 |
|
1 2 3 4 5 6 7 8 9 10 |
|
Virtualenv and PEP 582#
PDM offers experimental support for PEP 582 as an opt-in feature, in addition to virtualenv management. Although the Python Steering Council has rejected PEP 582, you can still test it out using PDM.
To learn more about the two modes, refer to the relevant chapters on Working with virtualenv and Working with PEP 582.
PDM Eco-system#
Awesome PDM is a curated list of awesome PDM plugins and resources.