You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the issue tracker and believe that this is not a duplicate.
Steps to reproduce
Update to PDM 2.5.0b1
Have an optional dependency, in my environment my pyproject.toml has:
[project.optional-dependencies]
build = [
...
]
Purge your lock-file:
❯ rm pdm.lock
Produce a lock file:
❯ pdm -vv lock --skip :post
🔒 Lock successful
Changes are written to pdm.lock.
Attempt to export the the optional dependency
❯ pdm -vv export --format requirements --without-hashes --group build
[PdmUsageError]: Requested groups not in lockfile: build
Attempt to add the missing optional dependency to the lockfile (or all optional dependencies)
❯ pdm -vv lock --group build --skip :post
[PdmUsageError]: Requested groups not in lockfile: build
❯ pdm -vv lock --group :all --skip :post
[PdmUsageError]: Requested groups not in lockfile: build
Purge the lockfile, and install with optional dependencies from the beginning, and attempt same operation:
❯ rm pdm.lock
❯ pdm -vv lock --group :all --skip :post
🔒 Lock successful
Changes are written to pdm.lock.
❯ pdm -vv export --format requirements --without-hashes --group build
The exported requirements file is no longer cross-platform. Using it on other platforms may cause unexpected result.
# This file is @generated by PDM.# Please do not edit it manually.
...
Actual behavior
Looking a little deeper, it looks like when the groups field is generated in the PDM lock by default it only includes dev-dependencies and the default, and not optional-dependencies. To get it to include optional-dependencies you need to include the relevant --group selector(s) (or :all).
This is fine, except once the lockfile is generated appears to use the lockfile as the source of truth for what groups are valid even when performing a lock operation, not the pyproject.toml. This means without purging the lockfile it is impossible to add a optional-dependency.
Give what I can see of the code, I also suspect that if you were to add an additional entry to dev-dependencies after this point you would similarly be able to add this to the lockfile, but I did not test this.
Expected behavior
When you create a lockfile it should either create the lockfile with the optional-dependencies included, or allow you to add optional-dependencies to the lockfile after initial generation.
Steps to reproduce
pyproject.toml
has:Actual behavior
Looking a little deeper, it looks like when the
groups
field is generated in the PDM lock by default it only includes dev-dependencies and thedefault
, and not optional-dependencies. To get it to include optional-dependencies you need to include the relevant--group
selector(s) (or:all
).This is fine, except once the lockfile is generated appears to use the lockfile as the source of truth for what groups are valid even when performing a lock operation, not the
pyproject.toml
. This means without purging the lockfile it is impossible to add a optional-dependency.Give what I can see of the code, I also suspect that if you were to add an additional entry to dev-dependencies after this point you would similarly be able to add this to the lockfile, but I did not test this.
Expected behavior
When you create a lockfile it should either create the lockfile with the optional-dependencies included, or allow you to add optional-dependencies to the lockfile after initial generation.
Environment Information
The text was updated successfully, but these errors were encountered: