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

Inconsistent via comments for backtracking resolver on constrained requirements #1712

Closed
mkniewallner opened this issue Oct 30, 2022 · 0 comments · Fixed by #1713
Closed
Labels
bug Something is not working resolver Related to dependency resolver

Comments

@mkniewallner
Copy link
Contributor

mkniewallner commented Oct 30, 2022

pip-compile generates inconsistent via comments when using backtracking resolver on constrained requirements.

When a constrained <constrained_requirements_file>.txt file is not yet generated, -c <requirements_file.txt> references are correctly added to via comments, but they are removed when re-compiling the requirements when the constrained <constrained_requirements_file>.txt file already exists.

This seems to apply only to the backtracking resolver, since I wasn't able to reproduce the issue using the legacy resolver.

Environment Versions

  1. OS Type: Linux (x86_64)
  2. Python version: 3.10.8
  3. pip version: 22.3
  4. pip-tools version: 6.9.0 (also tried on master branch, at commit 1fb2e69)

Steps to replicate

I've created a reproduction repository (https://github.com/mkniewallner/pip-compile-inconsistent-via-backtracking-resolver) with a README and commits history that highlight the issue, but basically:

  1. Create a requirements.in file with the following content:
starlette==0.21.0
  1. Create a requirements-dev.in file with the following content:
-c requirements.txt

httpx==0.22.0
  1. Run pip-compile --resolver=backtracking requirements.in
  2. Run pip-compile --resolver=backtracking requirements-dev.in
  3. Run pip-compile --resolver=backtracking requirements-dev.in again

Expected result

pip-compile writes the following requirements-dev.txt for both runs of pip-compile --resolver=backtracking requirements-dev.in:

#
# This file is autogenerated by pip-compile with python 3.10
# To update, run:
#
#    pip-compile --resolver=backtracking requirements-dev.in
#
anyio==3.6.2
    # via
    #   -c requirements.txt
    #   httpcore
certifi==2022.9.24
    # via
    #   httpcore
    #   httpx
charset-normalizer==3.0.0
    # via httpx
h11==0.12.0
    # via httpcore
httpcore==0.14.7
    # via httpx
httpx==0.22.0
    # via -r requirements-dev.in
idna==3.4
    # via
    #   -c requirements.txt
    #   anyio
    #   rfc3986
rfc3986[idna2008]==1.5.0
    # via httpx
sniffio==1.3.0
    # via
    #   -c requirements.txt
    #   anyio
    #   httpcore
    #   httpx

Actual result

The first time pip-compile --resolver=backtracking requirements-dev.in is run (where requirements-dev.txt doesn't yet exist), the correct requirements-dev.txt is generated:

#
# This file is autogenerated by pip-compile with python 3.10
# To update, run:
#
#    pip-compile --resolver=backtracking requirements-dev.in
#
anyio==3.6.2
    # via
    #   -c requirements.txt
    #   httpcore
certifi==2022.9.24
    # via
    #   httpcore
    #   httpx
charset-normalizer==3.0.0
    # via httpx
h11==0.12.0
    # via httpcore
httpcore==0.14.7
    # via httpx
httpx==0.22.0
    # via -r requirements-dev.in
idna==3.4
    # via
    #   -c requirements.txt
    #   anyio
    #   rfc3986
rfc3986[idna2008]==1.5.0
    # via httpx
sniffio==1.3.0
    # via
    #   -c requirements.txt
    #   anyio
    #   httpcore
    #   httpx

The second time pip-compile --resolver=backtracking requirements-dev.in is run (where requirements-dev.txt exists), the following diff is applied:

diff --git a/requirements-dev.txt b/requirements-dev.txt
index eaaa0f0..70ed934 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -5,9 +5,7 @@
 #    pip-compile --resolver=backtracking requirements-dev.in
 #
 anyio==3.6.2
-    # via
-    #   -c requirements.txt
-    #   httpcore
+    # via httpcore
 certifi==2022.9.24
     # via
     #   httpcore
@@ -22,14 +20,12 @@ httpx==0.22.0
     # via -r requirements-dev.in
 idna==3.4
     # via
-    #   -c requirements.txt
     #   anyio
     #   rfc3986
 rfc3986[idna2008]==1.5.0
     # via httpx
 sniffio==1.3.0
     # via
-    #   -c requirements.txt
     #   anyio
     #   httpcore
     #   httpx
@atugushev atugushev added bug Something is not working resolver Related to dependency resolver labels Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working resolver Related to dependency resolver
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants