-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Poetry export does not respect groups defined in lockfile #5779
Comments
It looks as though parsing the lockfile does not set The export can be fixed by an uglier check that diff --git a/src/poetry/packages/locker.py b/src/poetry/packages/locker.py
index c2a6c35c..d2b3db63 100644
--- a/src/poetry/packages/locker.py
+++ b/src/poetry/packages/locker.py
@@ -319,8 +319,9 @@ class Locker:
requirement.set_constraint(constraint)
for require in locked_package.requires:
- if require.in_extras and locked_package.features.isdisjoint(
- require.in_extras
+ if require.is_optional() and not any(
+ require in locked_package.extras[feature]
+ for feature in locked_package.features
):
continue But I'm not sure whether that's just putting a sticky plaster over the Or perhaps I've misunderstood Hard to tell. |
Would you be able to give me some guidance on where export ends up calling poetry/src/poetry/packages/locker.py Line 98 in 374cff5
I'd be happy to look into it with, and come up with a regression test case. Edit: I found this in the poetry-export package, will keep tracing through the code: https://github.com/python-poetry/poetry-plugin-export/blob/main/src/poetry_plugin_export/command.py#L15 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
-vvv
option).Issue
When running poetry export from the following pyproject.toml and poetry.lock, specifying various combinations of requirements do not result in an optional group excluded. The difference between the main group and the test group is that one of them specifies an extra from the dependency and one does not.
As you can see from the screenshot below,
poetry install
does what is expected given thepoetry.lock
andpyproject.toml
. However, exporting to requirements.txt does not. Given the difference in behavior between install and export to requirements, seems like there's something broken unless the difference in behavior is intended. From what I can tell based on documentation, it should be possible to completely eject apoetry.lock
file torequirements.txt
since the export includes similar options topoetry install
Project installing
git project being installed:
https://github.com/IndicoDataSolutions/poetry-install-from/blob/main/pyproject.toml, commit d6fb91081828c1644235b247f9757f1fb0f161a0
Poetry lock contents:
The poetry lock contents indicate that the extra was picked up correctly.
Result of running poetry export against the poetry.lock
I've experimented with various attempts like,
--only main
--> should only get the main group. but since mytest
group is defined as optional, it should not be picked up--without test
--> If test wasn't optional, this should exclude test group.The text was updated successfully, but these errors were encountered: