poetry-workspace-plugin
poetry-workspace-plugin copied to clipboard
Add workspace build command
Any related Github Issues?: add link here
What has changed? This should match CHANGELOG.md
.
This PR introduces a workspace build
command, which builds workspaces and replaces the directory reference of each workspace dependency with its version in the distribution manifest during packaging similarly to the way Cargo, Yarn and npm workspaces do.
Design choices:
Doesn't change the default poetry behavior
According to the poetry documentation, an application plugin shouldn't change the behavior of the default poetry commands. https://python-poetry.org/docs/master/plugins/. Thus, instead of augmenting poetry build
, I introduced a new plugin command poetry workspace build
.
Executable from the root or from within a workspace
The workspace build
command can be executed in the root package, in which case traverses each workspace and runs the build (with the augmented logic) in their respective environments. It can also be executed from within the confines of an individual workspace. This way it only builds the workspace for which it is invoked. To be able to discover the root (which is necessary for wiring the deps), I introduced a parent
field in tool.poetry-workspace-plugin
.
Alternative approaches:
- if we don't want to invoke
workspace build
from within a workspace, the parent project discovery is not required - we could do a recursive directory traversal up to the fs root to find the parent project instead
Configurable ranges
By default, workspace build
uses the exact version for each workspace dependency. However, following the design of workspaces in Yarn, we could allow for ranges. https://yarnpkg.com/features/workspaces
I propose following notation:
-
<empty string>
: exact version -
^
/~
: caret / tilde range on the exact version -
*
: any version (wildcard) -
.*
: minor wilcard (e.g4.1.2
->4.*
) (TBD) -
..*
: patch wildcard (e.g4.1.2
->4.1.*
) (TBD)
The code quality has to be improved and there are no test yet, but can be tried out in this example project: https://github.com/dszakallas/poetry-workspace-plugin-build-example
Check list
Before asking for a review
- [ ] Target branch is
master
- [ ] Implement tests
- [ ]
[Unreleased]
section in CHANGELOG.md is updated. - [ ] I reviewed the "Files changed" tab and self-annotated anything unexpected.
Before review (reviewer)
- [ ] All of the above are checked and true. Review ALL items. If not, return the PR to the author.
- [ ] Continuous Integration is passing. If not, return the PR to the author.
After merge (reviewer)
- [ ] Any issues that may now be closed are closed.