pdm-project / pdm

A modern Python package and dependency manager supporting the latest PEP standards
https://pdm-project.org
MIT License
7.79k stars 385 forks source link

simplify dev vs prod installs #3028

Open marcel-goldschen-ohm opened 1 month ago

marcel-goldschen-ohm commented 1 month ago

I'm new to PDM, so I probably am not be considering everything. However, I find it both non-intuitive and overly convoluted to swap between development and production installs. For example, consider a pyproject.toml with:

[project]
dependencies = [
    "mypackage"
]
[tool.pdm.dev-dependencies]
dev = [
    "-e mypackage @ file:///${PROJECT_ROOT}/path/to/mypackage",
]

where mypackage is both available via pypi and installed locally at path/to/mypackage for development.

For development only, things are simple. Running pdm install creates the pdm.lock file that refers to the local path/to/mypackage file and installs it in editable mode. Great!

However, as soon as I want to test the production version, things get tricky. I find it very non-intuitive that running pdm install --prod does not replace the local editable path/to/mypackage with the mypackage from pypi. I now understand that pdm.lock only refers to path/to/mypackage and not the mypackage from pypi. However, it is annoying to have to manually create a new lock file such as pdm lock --prod -L pdm.prod.lock and constantly refer to it with the extra flag -L pdm.prod.lock. Even so, running pdm install -L pdm.prod.lock still does NOT overwrite the editable path/to/mypackage that was installed for development. The non-intuitive solution after some digging is to run pdm install -L pdm.prod.lock --no-editable. Although this works, I find it both non-intuitive and overly complicated. Why can't pdm install --dev or pdm install --prod handle all of this including creating any appropriate lock files as needed?

I'm sure there is probably a good answer to this. However, as a new user I'd just say that I found this to be very frustrating.

Cheers

o-moe commented 1 month ago

Have you thought about creating a new virtualenv for testing your production environment and not reusing the development environment? Afaik, pdm can handle multiple ones - you still would need the extra lock file to my understanding, so this could, indeed, be more streamlined. Nevertheless, for me, I am using an additional environment to test productive behavior. I am not even using pdm to create it, just using pip because I assume that's what most users will do.

At the end, I have this automated as Gitlab pipeline that also does simple smoke tests (to see if the dependencies resolve ok etc.)

marcel-goldschen-ohm commented 1 month ago

Thanks @o-moe, I agree that this issue is fairly trivially solved. I simply find it a bit more convoluted than ideal, and I think new users would benefit from some additional recommendations for a typical development setup as I found the gotchas to be non-intuitive. Cheers.

marcel-goldschen-ohm commented 1 month ago

True, I’ll just have to put up with multiple lock files 😉 Thanks Sean.

Cheers, Marcel

From: Xuan (Sean) Hu @.> Date: Saturday, July 27, 2024 at 6:13 PM To: pdm-project/pdm @.> Cc: Goldschen, Marcel @.>, Author @.> Subject: Re: [pdm-project/pdm] simplify dev vs prod installs (Issue #3028)

AFAIK, the dev dependencies are used for lint/docs and tests, so local editable may not be the desired user case. Since we can not lock two versions of the same package in one lockfile, at least two lockfiles are needed for that I think.

— Reply to this email directly, view it on GitHubhttps://github.com/pdm-project/pdm/issues/3028#issuecomment-2254278399, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABYB6KUALH4HU54HS7OMGIDZOQSP7AVCNFSM6AAAAABLA47FDOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJUGI3TQMZZHE. You are receiving this because you authored the thread.Message ID: @.***>