-
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
Multiple environment markers doesn't work #7722
Comments
duplicate #5506 I expect |
I don't think so. #5506 is about one multiple-constraints dependency and one restricted (single constraint) dependency, which somehow depend on each other. At first glance this looks as if it should work except when local version identifiers are involved. Then, it could be a duplicate of some other issue. @marhoy Which versions are locked. Can you share your lock file? |
you should provide an explicit That's still not enough, though, this fix looks like it should finish the job: diff --git a/src/poetry/puzzle/provider.py b/src/poetry/puzzle/provider.py
index ed88b57d..79271517 100644
--- a/src/poetry/puzzle/provider.py
+++ b/src/poetry/puzzle/provider.py
@@ -320,12 +320,10 @@ class Provider:
#
# We rely on the VersionSolver resolving direct-origin dependencies first.
direct_origin_package = self._direct_origin_packages.get(dependency.name)
- if direct_origin_package is not None:
- packages = (
- [direct_origin_package]
- if dependency.constraint.allows(direct_origin_package.version)
- else []
- )
+ if direct_origin_package is not None and direct_origin_package.satisfies(
+ dependency, ignore_source_type=False
+ ):
+ packages = [direct_origin_package]
return PackageCollection(dependency, packages)
packages = self._pool.find_packages(dependency) However that would require testcase updates and I'm not sure that I'm interested in this enough to bother! If anyone wants to pick this up, the above is my suggestion. |
@dimbleby please forgive me, as I'm fairly new to python, but if this isn't a common use-case, how to you usually deal with dependency development? I'm currently working on the same thing. I have a commonlib that I want to share between projects. In dev, I just want to be able to hack away on it, but when deploying to production, it should install a tagged version from a git repo. The workflow is quite similar to |
I have expressed no view on that. If this is a use case that you are interested in... well I suggested a direction for a fix, above. |
@dimbleby your solution is still incomplete because
They both look easy fixes, but I don't know if this is the right path. After all, the marker belongs to the dependency, not to the package, so the current code may be considered ok. On the other side I see that Another solution could be transforming I'll wait for your input on how to proceed, as my confidence on |
I don't think further change is needed, my suggestion still looks good to me!
Then |
I forgot to mention that I didn't in fact consider this part of the solution, as I honestly consider it more of a hack than a robust solution. If markers are incompatible then I shouldn't bother specifying a different source to let Poetry get the incompatibility, rigth? |
No, I don't think this is a hack. I don't agree that incompatible markers should always force poetry to choose different solutions eg a requirement like example = [
{ markers = "platform_machine == 'aarch64'", url = "https://example.com/example-1.0-py3-none-any.whl" },
{ markers = "platform_machine == 'x86_64'", version = "^1.0" },
] can and should be satisfied just by using the named wheel the current interpretation of not specifying a source is "any source will do", and that seems quite reasonable to me. |
True, and I agree that incompatible markers should not always force poetry to choose different solutions. But for the specific case of mixing direct origin dependencies and source dependencies, I wonder:
Still, I can at least provide a PR for the fix that you suggested, which needs to be done anyways. We can then decide to further iterate on it if issues keep coming, or simply provide more insightful documentation :) |
"source not specified" has to be treated as "any source will do" in case there is an direct dependency on a direct-origin package Then if that indirect dependency was not allowed to be satisfied by the direct-origin package, there could be no solution. |
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) and have included the output below.Issue
I'm trying to install a different version of
torch
, depending on the CPU. If I'm on the Raspberry Pi, I want to use the wheel from download.pytorch.org, otherwise I can install from pypi. (The reason for this is a cuda-dependency-issue, but that's not the point here).I have the following in my
pyproject.toml
The problem is that the marker-logic doesn't work: Poetry just installs the first of the two alternatives, and ignores the markes.
Am I doing something wrong?
The text was updated successfully, but these errors were encountered: