Skip to content
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 lock adds duplicate hashes when using multiple constraint dependences #6327

Closed
3 tasks done
intgr opened this issue Sep 1, 2022 · 4 comments · Fixed by #6389 or #6393
Closed
3 tasks done

poetry lock adds duplicate hashes when using multiple constraint dependences #6327

intgr opened this issue Sep 1, 2022 · 4 comments · Fixed by #6389 or #6393
Labels
kind/bug Something isn't working as expected

Comments

@intgr
Copy link
Contributor

intgr commented Sep 1, 2022

  • 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 (-vvv option).

Issue

With a dependency specification like

python-ldap = [
  { platform = "linux", version = "3.4.0" },
  { platform = "win32", url = "https://download.lfd.uci.edu/pythonlibs/archived/python_ldap-3.4.0-cp310-cp310-win_amd64.whl" },
]

Every time I run poetry lock --no-update, Poetry adds duplicated hashes for python-ldap to the poetry.lock file.

After the first lock command, the content ends with:

python-ldap = [
    {file = "python-ldap-3.4.0.tar.gz", hash = "sha256:60464c8fc25e71e0fd40449a24eae482dcd0fb7fcf823e7de627a6525b3e0d12"},
]

After the second run, it's:

python-ldap = [
    {file = "python-ldap-3.4.0.tar.gz", hash = "sha256:60464c8fc25e71e0fd40449a24eae482dcd0fb7fcf823e7de627a6525b3e0d12"},
    {file = "python-ldap-3.4.0.tar.gz", hash = "sha256:60464c8fc25e71e0fd40449a24eae482dcd0fb7fcf823e7de627a6525b3e0d12"},
]

Etc, every run adds yet another entry there.

The contents of the lockfile should be deterministic.

@intgr intgr added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Sep 1, 2022
@dimbleby
Copy link
Contributor

dimbleby commented Sep 1, 2022

relevant code should be this loop if anyone is interested in figuring out a fix:

for package in package_specs:
if package["name"] not in files:
files[package["name"]] = []
for f in package["files"]:
file_metadata = inline_table()
for k, v in sorted(f.items()):
file_metadata[k] = v
files[package["name"]].append(file_metadata)
if files[package["name"]]:
package_files = item(files[package["name"]])
assert isinstance(package_files, Array)
files[package["name"]] = package_files.multiline(True)
del package["files"]

I imagine we're getting two similar package_specs and not doing anything to de-duplicate the things they have in common

@radoering
Copy link
Member

All locked filenames/hashes are duplicated once for each direct origin dependency among the multiple constraints dependencies. This issue doesn't occur in poetry 1.1 because direct origin dependencies are always updated (even with --no-update flag). I created a PR to fix this regression.

@intgr
Copy link
Contributor Author

intgr commented Sep 5, 2022

Thanks! I can confirm that this is fixed in Poetry master branch.

@mkniewallner mkniewallner removed the status/triage This issue needs to be triaged label Sep 18, 2022
Copy link

github-actions bot commented 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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
4 participants