pdm-example-monorepo icon indicating copy to clipboard operation
pdm-example-monorepo copied to clipboard

pdm lock - all dependencies in dev-group

Open arturloewen opened this issue 1 year ago • 1 comments

Hi,

I'm using pdm for while now and I'm now experimenting with a monorepo. I currently have the issue, that pdm lock generates all dependencies in the dev-group. So using "pdm install --prod" in deployment will install nothing at all. Of course I could use "pdm install --dev", but I would like to exclude other dev-dependencies in deployment. This can be replicated here as well, as soon as the original pdm.lock-file is deleted and regenerated with a simple "pdm lock"-call. I assume this is based on the fact, that all subpackages are defined (as editables) in the dev section of [tool.pdm.dev-dependencies] in the pyproject.toml in the root-folder

Steps to reproduce:

  1. clone repository
  2. create virtual environment
  3. install pdm in venv
  4. delete pdm.lock
  5. run "pdm lock"

I'm currently using: PDM, version 2.17.3 Python 3.11.8

Am I missing something or is "pdm lock" not working as intended (anymore).

Adding the dependencies from dev in [tool.pdm.dev-dependencies] in the pyproject.toml in the root-folder as non-editable and running "pdm lock" will add the default group in pdm.lock as well. "pdm install --prod" now works. Although the documentation strictly speaks against using the same dependency in the dev- and default-group.

But there is also another issue and the reason why I found the issue above: Imagine I have two microservices as well as some own libraries used by these microservices in my monorepo. How can I install only the dependencies of the target microservice? "pdm install --prod -p services/service1" will result in "Candidate not found" for the own library. Just "pdm install --prod" will install all dependencies as well as both microservices bloating the Docker-image. "pdm export -p services/service1/ -L pdm.lock --no-hashes" doesn't generate an error but will also export all dependencies of the project. Is pdm not made for such a use case or am I missing something?

arturloewen avatar Aug 02 '24 16:08 arturloewen

pdm supports a series of options to select and unselect groups and you can get whatever groups you need. https://pdm-project.org/latest/usage/dependency/#select-a-subset-of-dependency-groups-to-install

frostming avatar Aug 02 '24 20:08 frostming