-
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 won't check for pre-releases during dependency resolving of non-direct dependencies #4405
Comments
I think I just hit this in Poetry 1.2.0b2, in a trivial project (created with
This is surprising because Edit: I'm no longer sure that my reproduction above is the same as the problem described in this issue, so I opened #5825 for mine. Edit: Seems like this was the right problem after all, so #5825 is closed as a duplicate of this one again. |
I've been poking at this for a while, and there seems to be two issues at-play in my repro-case (detailed in #5825):
However, the data being cached is affected by the constraint, specifically whether pre-releases are allowed. So in my case, this code sees I worked around this by just ignoring this cache, and always passing the constraint down to the provider. However, I suspect this is wrong if the code above is relying on this cache's behaviour to deliver the intersection of constraints. That would be reasonable except that implies that Poetry considers So the fix might actually be more complex if we need the If the intersecting behaviour of Edit: I noticed that the intersection behaviour is actually documented as During The repo gets the same set of version queries again, and this time because the only version of My initial attempt at a fix for this is to introduce a new However, this latter fix makes me suspicious that I'm actually working around a higher-level issue:
I confirmed this with the following test-case: def test_add_can_select_prereleases_subdependencies_when_really_necessary(
app: PoetryTestApplication, repo: TestRepository, tester: CommandTester
):
package_distro = get_package("opentelemetry-distro", "0.31b0")
package_distro.add_dependency(
Factory.create_dependency("opentelemetry-sdk", "1.12.0rc1")
)
package_distro.add_dependency(
Factory.create_dependency("opentelemetry-api", ">=1.3,<2.0")
)
package_sdk = get_package("opentelemetry-sdk", "1.12.0rc1")
package_sdk.add_dependency(
Factory.create_dependency("opentelemetry-api", "1.12.0rc1")
)
package_sdk_stable = get_package("opentelemetry-sdk", "1.11.1")
package_api = get_package("opentelemetry-api", "1.12.0rc1")
repo.add_package(package_distro)
repo.add_package(package_sdk_stable)
repo.add_package(package_sdk)
repo.add_package(package_api)
tester.execute("opentelemetry-distro")
expected = """\
Using version ^0.31b0 for opentelemetry-distro
Updating dependencies
Resolving dependencies...
Writing lock file
Package operations: 3 installs, 0 updates, 0 removals
• Installing opentelemetry-api (1.12.0rc1)
• Installing opentelemetry-sdk (1.12.0rc1)
• Installing opentelemetry-distro (0.31b0)
"""
assert tester.io.fetch_output() == expected
assert tester.command.installer.executor.installations_count == 3
content = app.poetry.file.read()["tool"]["poetry"]
assert "opentelemetry-distro" in content["dependencies"]
assert content["dependencies"]["opentelemetry-distro"] == "^0.31b0" This is the same test-case as the one I created in #5825, but without So I'm thinking that a wider change is needed, that I have pushed the first fix attempt (that fails |
As noted in python-poetry#4405 (comment), I think this fix is probably wrong, and filtering out pre-release versions should be handled at a higher layer.
I am running into this issue also. Specifically in a similar situation to @TBBle with Opentelemetry. Interally, we have a data generation package that uses Sum up:
Results: To further test this, I pushed out a version of Package A that explicitly lists a dependency on I would expect these to resolve just fine, especially if |
Also see python-poetry/poetry#4405, though not the same issue entirely.
I only see one reproducer in this thread, and it works fine today $ poetry init -n
$ poetry add --lock opentelemetry-distro==0.31b0
Updating dependencies
Resolving dependencies... (0.2s)
Writing lock file
$ poetry export --without-hashes
Warning: poetry-plugin-export will not be installed by default in a future version of Poetry.
In order to avoid a breaking change and make your automation forward-compatible, please install poetry-plugin-export explicitly. See https://python-poetry.org/docs/plugins/#using-plugins for details on how to install a plugin.
To disable this warning run 'poetry config warnings.export false'.
deprecated==1.2.14 ; python_version >= "3.10" and python_version < "4.0"
opentelemetry-api==1.12.0rc1 ; python_version >= "3.10" and python_version < "4.0"
opentelemetry-distro==0.31b0 ; python_version >= "3.10" and python_version < "4.0"
opentelemetry-instrumentation==0.31b0 ; python_version >= "3.10" and python_version < "4.0"
opentelemetry-sdk==1.12.0rc1 ; python_version >= "3.10" and python_version < "4.0"
opentelemetry-semantic-conventions==0.31b0 ; python_version >= "3.10" and python_version < "4.0"
setuptools==69.1.0 ; python_version >= "3.10" and python_version < "4.0"
typing-extensions==4.9.0 ; python_version >= "3.10" and python_version < "4.0"
wrapt==1.16.0 ; python_version >= "3.10" and python_version < "4.0" NB various pre-releases resolved as expected I guess this should be closed |
A quick poke at the history of the relevant file suggests #7978 was the fix, appearing in Poetry 1.5.1 and later. Note for self: Before cleaning up https://github.com/TBBle/poetry/tree/allow-exact-pre_release-child-dependencies, check that both tests now pass. #7978 only tests one of the two cases I had in those patches. (The might correctly resolve both cases, but I'm too far from this code these days to be sure, and didn't have a public test-case to reproduce the second case, i.e. if no |
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
So, I have three python libs all of them are managed by poetry.
All libs are building fine and can be uploaded to a repository.
lib-b and lib-c are dependencies of lib-a, so far so good.
I changed the python version dependency of all three libs to
And all lib versions are pre-release semver version (i.e. 0.1.2-alpha.0, etc.) so, there are no major.minor.patch versions for now.
The dep lines for lib-a to add lib-b and lib-c as deps are looking like this:
doing a
poetry install
with this, it all works smooth and nicely.Now I created a tool which is using lib-a as direct dependency,
pyproject.toml
looks like this:Now lib-a has a pre-release version number, lib-b and lib-c too. lib-a pulls in lib-b and lib-c and it also references
allow-prereleases=true
.Expectation would be that
poetry install
would check all python version deps from lib-a and it would also check the python version deps from lib-b and lib-c and also takesallow-prerelease=true
setting for these two libs in lib-a into account.Sadly, it breaks, telling me that lib-a is not compatible with the
awesome-project
python version setting, because lib-a checks for lib-b and lib-c not for the pre-release versions, only formajor.minor.patch
versions. Which is obviously not available.Now, to test that this assumption is true, I updated lib-b and lib-c version to a
major.minor.patch
version, uploaded them to my local pypi repo,poetry update
d lib-a (still using pre-release version number) and uploaded this to my local pypi repo.Now for
awesome-project
doing apoetry install
and it magically works now. all the same settings, just the version numbers of lib-b and lib-c changed.Real bug is now: poetry won't check for pre-releases during dependency resolving of non-direct dependencies. Even when the version requirements are correctly set in the generated
setup.py
of the uploaded tarball.I know dependency resolving is not easy, especially in python :) But during development you don't want to rely on the "latest stable" version of a library (direct or indirect), I guess there needs to be a fix for this issue.
The text was updated successfully, but these errors were encountered: