How to handle services inside a monorepo?
Hi,
In the example there is only one folder, packages.
How to handle a scenario were also a folder services exists?
That folder would contain for example api-service, backend-service and similar, and those services use packages.
If we create the .lock file in the root there will also be created the .venv.
But how to run a specific service and make it use the root .venv?
I personally would prefer each service to have it's own .lock file, but in the docs I can only find this sentence: "And you can create only one pdm.lock file to lock all dependencies.".
Lock files usually correspond to virtual environments, so it is best to have one lock file per environment.
How to handle a scenario were also a folder
servicesexists?
It's the same, add the dependencies as editable in pyproject.toml: https://github.com/pdm-project/pdm-example-monorepo/blob/main/pyproject.toml
The question remains still open: Is it allowed to create a .lock file per service?
Why this question? Because:
- a service will never import another service (no dependency)
- services usually run on separate hardware (servers), so why to install dependencies of all services to just run one service?
- upgrading libraries or python versions becomes more difficult since you could end up having to update all services at once
The question remains still open: Is it allowed to create a .lock file per service?
why not, you are free to create any number of lock files you like and specify the path when running commands: https://pdm-project.org/en/latest/usage/lockfile/#specify-another-lock-file-to-use