Repository navigation
Description
- Poetry version: 1.2.1
- Python version: 3.10.6
- OS version and name: macOS 10.15.7
- pyproject.toml: https://gist.github.com/seansfkelley/fe46b800efa747f9917f9979a4757874
- I am on the latest stable Poetry version, installed using a recommended method.
- I have searched the issues of this repo and believe that this is not a duplicate.
- I have consulted the FAQ and blog for any relevant entries or release notes.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption) and have included the output below.
Possibly related: #3561, #6215, #5506,
Issue
When I attempt poetry install on macOS, Poetry tries to install torch=1.11.0+cpu, which does not have appropriate native builds:
poetry install
Installing dependencies from lock file
Package operations: 1 install, 0 updates, 0 removals
• Installing torch (1.11.0+cpu): Failed
RuntimeError
Unable to find installation candidates for torch (1.11.0+cpu)
at ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/chooser.py:103 in choose_for
99│
100│ links.append(link)
101│
102│ if not links:
→ 103│ raise RuntimeError(f"Unable to find installation candidates for {package}")
104│
105│ # Get the best link
106│ chosen = max(links, key=lambda link: self._sort_key(package, link))
107│
If I remove the non-Darwin option and leave only this one:
{ version = "1.11.0", markers = "sys_platform == 'darwin'", source = "pypi" }
Poetry installs it without issue.
If I instead replace the non-PyPI option with some other, distinct option and remove the pytorch legacy source:
{ version = "1.12.0", markers = "sys_platform != 'darwin'", source = "pypi" }
(note the version and source are different from the original non-Darwin option)
I can then freely change around the markers on both versions and reinstall and it will always select the intended version according to the rules.
The behavior of apparently ignoring markers only seems to happen when the source is not PyPI.
The non-Darwin source is used in a Docker build, and, if I remove the multiple options and simply set torch = "1.11.0+cpu", I am able to correctly install torch==1.11.0+cpu in my Docker build using this source configuration.
Activity
radoering commentedon Oct 5, 2022
Duplicates #5205 (comment). Will be fixed in upcoming 1.3 via #6679
seansfkelley commentedon Oct 5, 2022
#6679 does not appear to resolve this. This morning I installed Poetry from master:
The self-reported version is only
1.3.0.dev0and doesn't specify the commit hash. I assume this includes the fix, but I don't know how to check which exact commit is running.Using the same pyproject.toml linked in the original comment:
The lockfile format has changed a lot and it does seem to keep them separate as indicated in #6679, but the net effect is the same.
poetry.lock
dimbleby commentedon Oct 5, 2022
1.11.0and1.11.0+cpuare too similar: local versions are supposed to be fully compatible with the original.So at install time when looking in the lockfile for something that satisfies
1.11.0, poetry is happy to choose1.11.0+cpu: that's supposed to be compatible with1.11.0, and also more recent.I don't see anything much to be done about this.
radoering commentedon Oct 5, 2022
But shouldn't we consider the locked package source?
dimbleby commentedon Oct 5, 2022
At installation time poetry is presented with the following puzzle: "install
torch=1.11.0, the options available to you are per this lockfile".Considering only version constraints and markers the
1.11.0+cpupackage is then the best solution.seansfkelley commentedon Oct 5, 2022
I agree that PyTorch's packaging is a bit odd and the whole
cpualternate build would maybe benefit from being specified using extras instead. That said, the way I understandmarkers(at least in this case) is that this version specification should be treated as if it doesn't exist for the purposes of installing on macOS.Edit to respond:
It doesn't seem to be considering the markers, because
+cpuis not a legal choice on my system, right?neersighted commentedon Oct 5, 2022
The intention was to keep them separate as per #6679 -- they are interchangeable versions, but I should be able to specify two identical package specs from different sources, and get the correct version from the specified source based on my multiple constraint markers.
dimbleby commentedon Oct 5, 2022
hmm, maybe some sort of fix around https://github.com/python-poetry/poetry/blob/master/src/poetry/puzzle/provider.py#L860-L864 could work
dimbleby commentedon Oct 5, 2022
maybe as simple as
??
where the condition being tweaked represents "the dependency doesn't care from what source it is satisfied"
But I'll leave it to someone more motivated to add a unit test proving the point
dimbleby commentedon Oct 5, 2022
actually I think it's all a bigger mess than that
Dependencycallssource_nameis stored assource_referenceon aPackage. Probably thesource_nameattribute should be removed altogether, in favour ofsource_reference, so that these became consistent.Dependencywith an explicitsource_nameis not universally satisfied by any packageis_same_source_as()ought to know something about all of this - it currently believes that if both packages have source typeNonethen "no need to check further"Noneto mean "I don't care" on dependencies but "pypi" on packages is pretty confusingugh...
radoering commentedon Oct 15, 2022
The other PR is still required for a fix.
github-actions commentedon Mar 1, 2024
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.