PDM Build Locked

0.3.7 · active · verified Thu Apr 16

pdm-build-locked is a PDM plugin that adds locked packages as additional optional dependency groups to the distribution metadata. This enables reproducible installs of Python CLI tools by allowing users to install exact dependency versions from a PDM lockfile, preventing breakage on dependency updates. It is compatible with PDM versions >=2.11 and is currently at version 0.3.7.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set up a project using `pdm-build-locked`. It involves creating a PDM project, adding `pdm-build-locked` as a development dependency, configuring `pyproject.toml` to enable the plugin, building the distribution with the `--locked` flag, and then installing the resulting wheel with the `[locked]` extra, which pulls in the exact dependency versions specified in your `pdm.lock` file. Remember to replace 'my_cli_app-0.1.0-py3-none-any.whl' with the actual filename generated in your `dist/` directory.

# 1. Create a new PDM project and add a dependency
mkdir my_cli_app
cd my_cli_app
pdm init --backend pdm-backend --static-version --no-interaction
pdm add rich

# 2. Add pdm-build-locked to your project (if not installed globally)
pdm add --dev pdm-build-locked

# 3. Configure pyproject.toml to use pdm-build-locked
#    Add the following to your pyproject.toml manually or via script:
# [tool.pdm-build-locked]
# backend = 'pdm-backend'
#
# 4. Ensure the plugin is active (if not already via `pdm self add`)
pdm install

# 5. Build the project with locked dependencies
pdm build --locked

# 6. Install the resulting wheel with locked dependencies
#    (Replace 'my_cli_app-0.1.0-py3-none-any.whl' with your actual wheel file name)
pip install dist/my_cli_app-0.1.0-py3-none-any.whl[locked]

# To verify, you can check installed packages or run your CLI app

view raw JSON →