Repository navigation
Description
- I am on the latest Poetry version.
- I have searched the issues of this repo and believe that this is not a duplicate.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption).
- OS version and name: MacOS Big Sur 11.2.3
- Poetry version: 1.1.6
Issue
I encountered an issue with dependencies when using a private repository. I have a pyproject.toml like
[tool.poetry]
name = "my-awesome-package"
version = "0.1.0"
description = "My package."
authors = ["Me"]
packages = [
{ include = "sub_package_1" },
{ include = "sub_package_2" }
]
include = ["path_to_files/**/*.gz"]
[[tool.poetry.source]]
name = 'private_pypi'
url = 'https://mypypi.dom/pypi/simple'
[tool.poetry.dependencies]
python = "^3.7"
[tool.poetry.dev-dependencies]
[build-system]
build-backend = "poetry.masonry.api"
requires = ["poetry>=1.1.2"]And I'd like to add a new package, explicitly poetry add rasterio.
When the private repository (which has nothing to do with the desired package) is present in pyproject.toml, only
the package itself gets installed without its dependencies
poetry add rasterio
Using version ^1.2.3 for rasterio
Updating dependencies
Resolving dependencies... (10.2s)
Writing lock file
Package operations: 1 install, 0 updates, 0 removals
• Installing rasterio (1.2.3)
When I remove the private repository part
[[tool.poetry.source]]
name = 'private_pypi'
url = 'https://mypypi.dom/pypi/simple'and try to add the package, all of its dependencies get installed correctly
poetry add rasterio
Using version ^1.2.3 for rasterio
Updating dependencies
Resolving dependencies... (3.5s)
Writing lock file
Package operations: 6 installs, 0 updates, 0 removals
• Installing click (7.1.2)
• Installing affine (2.3.0)
• Installing click-plugins (1.1.1)
• Installing cligj (0.7.1)
• Installing snuggs (1.4.7)
• Installing rasterio (1.2.3)
It seems that the private repository is somehow interfering with the resolution of the dependencies.
I have tried to recreate both the poetry.lock file and the virtual environment from scratch with no change in this behaviour.
Initially, I have discovered this issue through a transitive dependency (a dependency on the private pypi repository, which I was trying to install, depends on rasterio) when I tried to poetry update, the dependencies affine, click-plugins , snuggs and cligj got uninstalled, so the issue seemed to be related to #3224 and #3684, but the issue can be reproduced with this minimalistic setup.
I have specified the missing dependencies explicitly in the pyproject.toml file for the time being. This however is a suboptimal solution as it bloats pyproject.toml.
Thank you for your help!
Activity
Korijn commentedon Aug 25, 2021
See #4439 sounds like it could be your problem
neersighted commentedon Oct 5, 2022
I cannot reproduce this on 1.2.x -- if you are still running into this, please comment back here with a model project that demonstrates the issue/reproduces it for you.
theirix commentedon Dec 7, 2022
Reproduced with Poetry 1.2.2 / macOS 12.6.1 (21G217) with exactly this package
rasterio.The
pyproject.toml:Commands:
If I don't use a private repository, all dependencies are installed as expected:
theirix commentedon Dec 21, 2022
@neersighted newest 1.3.1 still has this issue. I think this bug should be reopened.
neersighted commentedon Dec 21, 2022
I'm still unable to reproduce this against devpi. Can you please provide
poetry addin verbose mode, as well as the precise command you're using to add a custom source? How are you communicating the credentials to Poetry? They should be added usingpoetry config.theirix commentedon Jan 19, 2023
I decided to reread the documentation about secondary package sources. My scenario was about publishing private packages to the private repository. It is not the same as using the private repository as a full PyPI mirror.
So in my example, I hadn't marked the repository as secondary (no
secondary = truein my snippet above). So poetry expects to find all packages in a private repository, even those that weren't published to the secondary repository. After marking it as a secondary, poetry successfully installs arasteriopackage with all its dependencies.mbbyn commentedon Mar 5, 2023
Hello,
We are facing the same issue, and I'm not sure anyone posted the
-vvvlogs before, so I will add it from our side.I'm using poetry to install tensorflow 2.11.0 from devpi, however, it is resolving the dependencies differently than if the sources was PyPI directly. I can also provide a full reproduce case with docker-compose, as we use docker for both devpi and poetry.
Here is the basic output below when trying to install tensorflow from PyPI vs. devpi. It seems poetry is installing the tensorflow (intel / aws), causing it to detect circular dependencies, and eventually failing silently.
Using the following versions:
Python 3.10.9
Poetry 1.3.2 or 1.4.0
devpi-server 6.8.0
Worth noting:
mbbyn commentedon Mar 6, 2023
Problem
I tried to inspect it further today, and noticed that the package definition is somehow different based on the source (PyPI vs devpi). Notice how the requires for tensorflow is empty from PyPI but has two false positives for devpi. Also, it seems the python markers and other constraints are completely missing.
Just a hunch, I noticed poetry treats "legacy" source the same way it treats local cache. Perhaps this is bypassing full dependency resolution?Root Cause
The issue is basically this:
poetry/src/poetry/repositories/http_repository.py
Lines 112 to 120 in f27308f
I stopped the debugger here:
poetry/src/poetry/repositories/http_repository.py
Lines 208 to 210 in f27308f
And by getting the metadata from the linux x86 wheel, the
requires_distshowed correctly. I think the issue is two fold:requires_distregardles of markers.Debug: Package Info Parsing from Wheel vs. JSON (Legacy vs. PyPI)
This shows the wheel metadata extracted from Legacy index. I wanted to use it as a test case, but I couldn't find the best place in the unit tests to test the
LegacyRepositoryresolving this metadata.On the other hand, this is the package info from PyPI.
Require dist are completely different!
Debug: Package object
Here is a cleaned up diff to see the difference between Package objects PyPI vs Legacy + the stack trace for it:
https://editor.mergely.com/zDeiGtTI/
mbbyn commentedon Mar 6, 2023
Hacky Solution
Here is a hacky solution for the impatient. Only tested on our linux docker image pipeline.
Use at your own risk!
The patch script:
In the Dockerfile:
dimbleby commentedon Mar 6, 2023
the assumption that all distributions of a particular version of a package share metadata is unlikely to be dropped from poetry: cross-platform builds bring enough complication without trying to add another dimension (not to mention the performance implications of having to download every distribution separately in case it has different metadata).
this assumption about same-metadata-on-all-distributions is poetry's rather than a spec requirement (though some of us think that it ought to be!) so tensorflow is not "wrong" here: however it is incompatible with the approach that poetry takes.
in tensorflow/tensorflow#58770 I see that tensorflow moved in the direction of using the same metadata everywhere, I think as an explicit concession to poetry, but that work looks at best incomplete.
well, perhaps that shows a willingness that you can use. ie probably your best bet is to make a merge request at tensorflow to complete the job that was started there: to make it true that the same metadata is expressed in all tensorflow distributions, using markers to spell out which bits are relevant on which platforms.
Mazyod commentedon Mar 6, 2023
@dimbleby could we perhaps appease to the “performance implication” part, and suggest the following:
“Downloading the first wheel, which may very well be incompatible, would downgrade performance when the actual wheel needed will probably be downloaded anyway later down the line. Picking the correct wheel from this stage is an optimization, which also happens to have a nice side-effect of fixing legacy repos”.
😄?
dimbleby commentedon Mar 6, 2023
it's not an optimization, though, because wheels downloaded at this point aren't cached. So downloading the platform-compatible one at this point wouldn't save a later download.
we discussed this at #6547 (comment) and took the position that it was better to encourage packagers to publish consistent metadata. (Also there was a meaningful performance hit)
I'm not 100% against "prefer a platform-compatible wheel": but cross-platform builds are important to poetry and poetry users, and unless metadata is consistent then it can't achieve that.
I'd definitely recommend that one of you who cares about this at least try submitting an MR to tensorflow!
mbbyn commentedon Mar 7, 2023
EDIT
Just saw the comment on TF issue. My whole assumption was based on the fact that the wheel metadata mistmatch is not part of the standard, but if so, then for sure the best way forward is to fix TF and any other misbehaving packages.
(In the meantime, this plugin might help: https://github.com/Mazyod/poetry-legacy-index)
@dimbleby TF is a downstream dependency for us, and could take 6 months or more to be resolved on our side. Sure, would be good for the long run, but as app developers (sorry for the cynicism) but we care mostly about our stuff working, rather than the ecosystem as a whole.
Regardless though, appreciate your time and thoughts on the subject!
nfantone commentedon Apr 22, 2024
Happened to hit the same thing today with
pydantic. I can easily reproduce it with a blank project using the belowpyproject.toml. Removing the comments to enable a customtool.poetry.sourcemakespoetry installignore allpydanticdependencies (see logs further down).Using version ^2.7.0 for pydantic Updating dependencies Resolving dependencies... (0.2s) Package operations: 4 installs, 0 updates, 0 removals - Installing typing-extensions (4.11.0) - Installing annotated-types (0.6.0) - Installing pydantic-core (2.18.1) - Installing pydantic (2.7.0) Writing lock fileUsing version ^2.7.0 for pydantic Updating dependencies Resolving dependencies... (0.1s) Package operations: 1 install, 0 updates, 0 removals - Installing pydantic (2.7.0) Writing lock fileEnvironment:
poetry1.8.2.python3.12.3.dimbleby commentedon Apr 22, 2024
not the same thing
I think this one should be closed, it seems to have boiled down to "poetry assumes that all distributions of a package provide the same metadata and goes wrong when that is not true" - which is indeed the case, but I think there is very little chance that poetry will change anything on that front.
(packages that don't follow this pattern should be considered not poetry-compatible, and if their maintainers care about that then they should provide consistent metadata.)
nfantone commentedon Apr 22, 2024
Not sure about it "not being the same thing" (definitely the same symptoms) — but managed to fix it by following this comment, which solved it for me.
Essentially:
Seems like a bug of sorts to me.
dimbleby commentedon Apr 22, 2024
still not the same thing, but a duplicate of a dozen others (including the one that you found), please stop polluting this unrelated issue