Skip to content

dependency-group with key "default" is ignored #3609

@freidrichen

Description

@freidrichen

Describe the bug

If my pyproject.toml includes a dependency-group with key "default", that group is ignored by pdm and isn't included in the lock file when doing pdm lock -d.

To reproduce

With this pyproject.toml:

[project]
name = "dependency-groups-test"
requires-python = ">=3.12"

[dependency-groups]
default = [
    "numpy>=2.0.0",
]
more = [
    "psutil>=5.8.0",
]

I run pdm lock -d. The resulting pdm.lock doesn't include numpy:

# This file is @generated by PDM.
# It is not intended for manual editing.

[metadata]
groups = ["default", "more"]
strategy = ["inherit_metadata"]
lock_version = "4.5.0"
content_hash = "sha256:9dcd67af0a3a6d0defa9dbe1116a5d1275ef473d201ce70c70b73740c0f01bc7"

[[metadata.targets]]
requires_python = ">=3.12"

[[package]]
name = "psutil"
version = "7.0.0"
requires_python = ">=3.6"
summary = "Cross-platform lib for process and system monitoring in Python.  NOTE: the syntax of this script MUST be kept compatible with Python 2.7."
groups = ["more"]
files = [
    {file = "psutil-7.0.0-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:101d71dc322e3cffd7cea0650b09b3d08b8e7c4109dd6809fe452dfd00e58b25"},
    {file = "psutil-7.0.0-cp36-abi3-macosx_11_0_arm64.whl", hash = "sha256:39db632f6bb862eeccf56660871433e111b6ea58f2caea825571951d4b6aa3da"},
    {file = "psutil-7.0.0-cp36-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1fcee592b4c6f146991ca55919ea3d1f8926497a713ed7faaf8225e174581e91"},
    {file = "psutil-7.0.0-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4b1388a4f6875d7e2aff5c4ca1cc16c545ed41dd8bb596cefea80111db353a34"},
    {file = "psutil-7.0.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a5f098451abc2828f7dc6b58d44b532b22f2088f4999a937557b603ce72b1993"},
    {file = "psutil-7.0.0-cp37-abi3-win32.whl", hash = "sha256:ba3fcef7523064a6c9da440fc4d6bd07da93ac726b5733c29027d7dc95b39d99"},
    {file = "psutil-7.0.0-cp37-abi3-win_amd64.whl", hash = "sha256:4cf3d4eb1aa9b348dec30105c55cd9b7d4629285735a102beb4441e38db90553"},
    {file = "psutil-7.0.0.tar.gz", hash = "sha256:7be9c3eba38beccb6495ea33afd982a44074b78f28c434a1f51cc07fd315c456"},
]

pdm lock -d -G :all and pdm lock -d -G default all give the same result.

Expected Behavior

Numpy is locked and included in the group "default".

Environment Information

PDM version:
  2.25.6
Python Interpreter:
  /home/freidrichen/.pyenv/versions/3.12.10/envs/sy-312/bin/python (3.12)
Project Root:
  /home/freidrichen/jobb/pdm-dep-groups-test
Local Packages:
  
{
  "implementation_name": "cpython",
  "implementation_version": "3.12.7",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "5.15.0-135-generic",
  "platform_system": "Linux",
  "platform_version": "#146-Ubuntu SMP Sat Feb 15 17:06:22 UTC 2025",
  "python_full_version": "3.12.10",
  "platform_python_implementation": "CPython",
  "python_version": "3.12",
  "sys_platform": "linux"
}

Verbose Command Output

pdm lock -d -v

pdm.termui: ======== Start resolving requirements ========
pdm.termui:   psutil>=5.8.0
pdm.termui:   Adding requirement python>=3.12
pdm.termui:   Adding requirement psutil>=5.8.0
pdm.termui: ======== Starting round 0 ========
pdm.termui: Adding new pin: python None
pdm.termui: ======== Starting round 1 ========
pdm.termui: Adding new pin: psutil 7.0.0
pdm.termui: ======== Starting round 2 ========
pdm.termui: ======== Resolution Result ========
pdm.termui:   python None
pdm.termui:   psutil 7.0.0
pdm.termui: Fetching hashes for psutil@7.0.0
Changes are written to pdm.lock.

Additional Context

No response

Are you willing to submit a PR to fix this bug?

  • Yes, I would like to submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions