Repository navigation
feat(workspace): support PDM workspaces - #31
Merged
Merged
Conversation
Workspace support relies on the `Project` workspace API introduced in PDM 2.28.0 (`workspace_project`, `is_workspace_root`, `iter_members`, `with_workspace_dependencies`).
`get_backend_by_spec()` falls back to `pdm.backend` when the project has no `[build-system]` table, so a non-distribution project having a `src` directory got it added to `PYTHONPATH`, pointing at a directory which is never copied into the image. Skip the package dir entirely for non-distribution projects: they have no sources of their own.
Requirement lines were passed verbatim to `uv pip install`, so an editable
requirement produced a single `-e <url>#egg=<name>` argv token, and PDM's
`file:///${PROJECT_ROOT}/...` placeholder was never expanded.
`uv` has no equivalent of PDM's `no_editable`, so rewrite editable
requirements as non-editable PEP 508 direct references, keeping the image
self-contained, and expand the requirement line through the project build
backend.
Workspace members are implicit `default` dependencies of the workspace root, but PDM only injects them when locking, so they ended up in the lock file without ever being installed. Members are now installed, as regular non-editable packages, along with their console scripts. As members share a single lock file and environment, `dockerize` is restricted to the workspace root, like `install`, `lock` and `sync`.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #31 +/- ##
==========================================
+ Coverage 94.06% 94.82% +0.76%
==========================================
Files 6 6
Lines 438 464 +26
Branches 61 69 +8
==========================================
+ Hits 412 440 +28
+ Misses 22 21 -1
+ Partials 4 3 -1 ☔ View full report in Codecov by Harness. |
`uv` generated lock files store workspace members without their location,
only a name, a version and the editable flag, so they are read back as
named requirements which can never be matched against the local path
requirements the workspace root implicitly depends on, failing with:
Missing package <member> from the lockfile, the lockfile may be broken.
Members are now given their path requirement back when reading the lock
file, and re-keyed accordingly, as the candidate identity depends on it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for PDM workspaces (requires
pdm>=2.28).Running
pdm dockerizefrom a workspace root now installs every workspace member along with their transitive dependencies, and exposes their console scripts. Members are installed as regular non-editable packages, so the resulting image stays self-contained and never references build-time host paths.Because members share a single lock file and a single environment,
dockerizeis restricted to the workspace root, consistently withinstall,lockandsync. Configuration is therefore read from the workspace root only.Two pre-existing bugs surfaced along the way and are fixed here as well:
uv pip install, which could not consume them. This affected any local path dependency underuv, not just workspaces.srcdirectory got it added toPYTHONPATH, pointing at a directory absent from the image.