-
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
Pass Install Extras to Markers #9553
Conversation
I will try to take a closer look at the end of the week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really good. Nice work. 👍
It looks like some of the changes are not tested yet or may be redundant. See separate comments for details.
Thank you so much for the great feedback here! All the comments make sense to me, I'm working through it and will submit updates and responses later this week |
How would this differentiate between the
poetry install -E cuda124 and define the in the package [tool.poetry.extras]
cuda124 = ["torch"] Here your suggestion would add [tool.poetry.dependencies]
python = "^3.10"
torch = [
{ markers = "extra == 'cuda124'", version = "2.4.0+cu124", optional = true},
^^^^^^
poetry add "pandas[aws]" which would show in the [tool.poetry.dependencies]
python = "^3.11"
pandas = {extras = ["aws"], version = "^2.2.2"}
^^^^^ Would the differentiation be made on the following?
If so, I must have misunderstood the docs because I thought these 2 syntaces express the same requirements/constraints |
I apologize for the long delay here, I had to pause this before I managed to finish all the updates. But it hasn't left my mind, and I'll be able to resume the updates in a couple weeks and will push them up and respond to everything in mid-September! Thanks for the patience |
@reesehyde Any update on this? Would love to have this feature available. ^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I apologize for the long delay here, I've been working on the suggested updates but uncovered an issue in the process. I've added a couple breaking tests which will hopefully help illuminate it. But I'm a little stuck on the best course of action, so would love a push in the right direction if you're able @radoering.
It seems that part of the reason the initial tests passed is because they used conflicting versions of torch
, which works only because they then go through the process of merging duplicates since the package name is the same in all cases.
However, dependencies with their own differing extras (e.g. torch[cpu]
and torch[cuda]
) are not considered duplicates, so they result in a SolverProblemError
.
Simply considering them duplicates creates its own issues (e.g. see the test_solver_resolves_duplicate_dependency_in_extra test). So we need some way to do overlapping marker resolution in these cases without breaking other solving cases.
Another possibility would be scoping this PR down to not support conflicting dependency extras, but I'm not certain how that would look.
@GeeCastro this is a great question, you're right that they are basically the same syntax! The problem comes up when you have conflicting extras, e.g. if the |
… with active root extras
4734c0f
to
ad85d88
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@radoering thank you again for all the help here! I've pushed updates, responded to all threads, and rebased on main
.
I believe everything has test coverage now, there are just small open questions on:
- Whether to leave redundant changes in both places or isolate to one place
- Either the L465 change or L558 change are sufficient to pass the new
test_installer
tests, but not sure if it's worth including both for "marker value correctness" or in cases where having both may shorten the solving steps required.
- Either the L465 change or L558 change are sufficient to pass the new
- Whether to leave or remove the changes and test which rely on root extra dependencies having the extra marker value even though it's not generally populated in those cases
- I added test coverage for the L623 change but you mentioned that test scenario may be unrealistic
Edit: The bug referenced was still present, but I added an improved test for it and finally found a fix. Final open question is:
- A review of that new logic
9136c55
to
33eed99
Compare
* origin/main: Upgrade minimal Cleo to 2.2.1 make `allow-prereleases` a tri-state setting to really forbid pre-releases if the setting is `false` and keep default behavior to allow pre-releases only if necessary feat: add confirmation step feat(cli): add info messages about applied migration docs: add information about --migrate feat(cli): add support for --local for --migrate feat(cli): add --migration option to config command feat(config): add ConfigSourceMigration feat(config): provide method to remove empty config category feat(config): add get_property() to ConfigSource Ignore http credentials with empty usernames Fix regression when using empty username/password fix index error for yanked releases without dependencies ignore installed packages during solving vcs: use peeled ref when retrieving tag revision (python-poetry#9849) chore: update json fixtures and improve generate script so that it produces the same results on Linux and Windows installer: add option to install without re-resolving (just by evaluating locked markers) (python-poetry#9427) - introduce "installer.re-resolve" config option (default: True) - if the config option is set to False and the lock file is at least version 2.1, the installer will not re-resolve but evaluate locked markers locker: lock transitive marker and groups for each package (python-poetry#9427) fix: do not ignore local config for implicit PyPI source (python-poetry#9816) Cleanup, linting, typing (python-poetry#9839) # Conflicts: # src/poetry/installation/installer.py # src/poetry/puzzle/solver.py
Deploy preview for website ready! ✅ Preview Built with commit cc566ea. |
… docs to new syntax
Trying out the examples, I unfortunately discovered some issues:
I did not find a solution for the second issue. In general, the issue is that on the one hand we want to filter unused extras in Unfortunately, |
Thanks for finding and fixing that bug @radoering!
On my investigation here I think the only thing that doesn't work are conflicts between "no extras" and "some extra" when installing the "no extras" case with re-resolve. For example, this can fail: [tool.poetry]
package-mode = false
[project]
name = "torch-test"
dependencies = [
"torch (==2.3.1+cpu) ; extra != 'cuda'",
]
[project.optional-dependencies]
cuda = [
"torch (==2.3.1+cu118)",
]
[tool.poetry.dependencies]
python = "^3.10"
torch = [
{ markers = "extra != 'cuda'", source = "pytorch-cpu"},
{ markers = "extra == 'cuda'", source = "pytorch-cuda"},
]
[[tool.poetry.source]]
name = "pytorch-cpu"
url = "https://download.pytorch.org/whl/cpu"
priority = "explicit"
[[tool.poetry.source]]
name = "pytorch-cuda"
url = "https://download.pytorch.org/whl/cu118"
priority = "explicit"
[build-system]
requires = ["poetry-core>=2.0.0"]
build-backend = "poetry.core.masonry.api" When installing with no extras and
However it works with But I think importantly the workaround is just to use exclusive extras, rather than the [tool.poetry]
package-mode = false
[project]
name = "torch-test"
[project.optional-dependencies]
cpu = [
"torch (==2.3.1+cpu)",
]
cuda = [
"torch (==2.3.1+cu118)",
]
[tool.poetry.dependencies]
python = "^3.10"
torch = [
{ markers = "extra == 'cpu' and extra != 'cuda'", source = "pytorch-cpu"},
{ markers = "extra != 'cpu' and extra == 'cuda'", source = "pytorch-cuda"},
]
[[tool.poetry.source]]
name = "pytorch-cpu"
url = "https://download.pytorch.org/whl/cpu"
priority = "explicit"
[[tool.poetry.source]]
name = "pytorch-cuda"
url = "https://download.pytorch.org/whl/cu118"
priority = "explicit"
[build-system]
requires = ["poetry-core>=2.0.0"]
build-backend = "poetry.core.masonry.api" This would also explain why all the tests succeed even with your new Updated the example, let me know what you think. |
Thanks for the update @reesehyde! I did not realize that the second example will work if I leave out the I updated the docs with your updated examples (with some minor adaptions):
Further, I added a warning that the first example will only work with |
Awesome, thanks so so much for all the help over these past months @radoering! 🙏 I may look more into whether it's possible to support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried everything so far and skimmed over the code again. I think it is ready to merge now. Thanks @reesehyde for your persistent work on this topic.
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Pull Request Check List
Resolves: #834
Improves: #6409
Resolves: #6419
Resolves: #7748
Resolves: #9537
This PR exposes the
extras
supplied at install to the 'extra' marker for dependencies, taking up @radoering's offer to create a PR implementing this functionality to allow switching torch installation versions based on acuda
extra.It is a duplicate of the feature in python-poetry/poetry-core#613 but it appears that PR is no longer active, with the last updates in August 2023 and an unanswered question about timeline from March 2024. This PR takes a different approach: I noticed that python-poetry/poetry-core#636 added special handling for the
extras
marker value but that marker isn't populated often, so I opted to populate the value when extras are specified in the installer.See issues and unit tests for more details but the idea is to, among other things, enable exclusive extras like so:
@radoering it looks like you're very familiar with this issue, would you be the right person to review? 🙏
I'm sure I'm missing something here but look forward to iterating!
Edit by @radoering: fix links to poetry-core PRs