PDM - Python package manager with PEP 582 support
Introduction - PDM

              
                
                  

  
  






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.8+ 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.8 or higher.
Like Pip, PDM provides an installation script that will install PDM into an isolated environment.
Linux/MacWindows

curl -sSL https://pdm-project.org/install-pdm.py | python3 -

powershell -ExecutionPolicy ByPass -c "irm https://pdm-project.org/install-pdm.py | py -"




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:
curl -sSLO https://pdm-project.org/install-pdm.py
curl -sSL https://pdm-project.org/install-pdm.py.sha256 | shasum -a 256 -c -
# Run the installer
python3 install-pdm.py [options]

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:
usage: install-pdm.py [-h] [-v VERSION] [--prerelease] [--remove] [-p PATH] [-d DEP]

optional arguments:
  -h, --help            show this help message and exit
  -v VERSION, --version VERSION | envvar: PDM_VERSION
                        Specify the version to be installed, or HEAD to install from the main branch
  --prerelease | envvar: PDM_PRERELEASE    Allow prereleases to be installed
  --remove | envvar: PDM_REMOVE            Remove the PDM installation
  -p PATH, --path PATH | envvar: PDM_HOME  Specify the location to install PDM
  -d DEP, --dep DEP | envvar: PDM_DEPS     Specify additional dependencies, can be given multiple times

You can either pass the options after the script or set the env var value.
Other installation methods#
HomebrewScoopuvpipxpipasdfinside project


scoop bucket add frostming https://github.com/frostming/scoop-frostming.git
scoop install pdm




Install the head version of GitHub repository.
Make sure you have installed Git LFS on your system.
pipx install git+https://github.com/pdm-project/pdm.git@main#egg=pdm

To install PDM with all features:

See also: https://pypa.github.io/pipx/



Assuming you have asdf installed.
asdf plugin add pdm
asdf local pdm latest
asdf install pdm



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:
Linux/MacWindows

curl -LO https://github.com/pyprojectx/pyprojectx/releases/latest/download/wrappers.zip && unzip wrappers.zip && rm -f wrappers.zip
./pw --add pdm

Invoke-WebRequest https://github.com/pyprojectx/pyprojectx/releases/latest/download/wrappers.zip -OutFile wrappers.zip; Expand-Archive -Path wrappers.zip -DestinationPath .; Remove-Item -Path wrappers.zip
.\pw --add pdm



When installing pdm with this method, you need to run all pdm commands through the pw wrapper:




Update the PDM version#

Uninstallation#
If you need to remove PDM from your system, you can use the following script:
Linux/MacWindows

curl -sSL https://pdm-project.org/install-pdm.py | python3 - --remove

powershell -ExecutionPolicy ByPass -c "irm https://pdm-project.org/install-pdm.py | py - --remove"



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:
BashZshFishPowershell

pdm completion bash > /etc/bash_completion.d/pdm.bash-completion # Requires root (sudo). For an alternative, see next
pdm completion bash > ~/.bash_completion # Does not require root (sudo). Installed only for your user account


# Make sure ~/.zfunc is added to fpath, before compinit.
pdm completion zsh > ~/.zfunc/_pdm

Oh-My-Zsh:
mkdir $ZSH_CUSTOM/plugins/pdm
pdm completion zsh > $ZSH_CUSTOM/plugins/pdm/_pdm

Then make sure pdm plugin is enabled in ~/.zshrc

pdm completion fish > ~/.config/fish/completions/pdm.fish

# Create a directory to store completion scripts
mkdir $PROFILE\..\Completions
echo @'
Get-ChildItem "$PROFILE\..\Completions\" | ForEach-Object {
    . $_.FullName
}
'@ | Out-File -Append -Encoding utf8 $PROFILE
# Generate script
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
pdm completion powershell | Out-File -Encoding utf8 $PROFILE\..\Completions\pdm_completion.ps1



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.


    
        
    










  




                
              
            