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

[2020-resolver] Fails if two versions with ; python_version in constraints for the same package #8724

Closed
akaihola opened this issue Aug 6, 2020 · 4 comments · Fixed by #8727
Labels
type: bug A confirmed bug or unintended behavior
Milestone

Comments

@akaihola
Copy link
Contributor

akaihola commented Aug 6, 2020

What did you want to do?
I want to install a different version of a package depending on the Python version.

constraints.txt:

Django==3.0.9 ; python_version >= "3.6"
Django==2.2.15 ; python_version < "3.6"
$ python -m venv /tmp/venv
$ . /tmp/venv/bin/activate
$ pip install -U pip
$ pip install -U "pip @ https://github.com/pypa/pip/archive/master.zip"
$ pip install --use-feature 2020-resolver --constraint constraints.txt Django

Output

ERROR: Could not find a version that satisfies the requirement Django
ERROR: No matching distribution found for Django

Additional information

Tried with

  • Python 3.7.7
  • Python 3.8.2
@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Aug 6, 2020
@uranusjr
Copy link
Member

uranusjr commented Aug 6, 2020

Does this happen if it’s a requirements file (-r) instead of constraints? This would help locate the problem greatly. Thanks!

@akaihola
Copy link
Contributor Author

akaihola commented Aug 6, 2020

@uranusjr no, it works perfectly with -r.

@akaihola
Copy link
Contributor Author

akaihola commented Aug 6, 2020

To make sure my environment doesn't interfere with anything, I created a Docker setup to test this.

/tmp/pip-issue-8724.sh:

#!/bin/bash

cat >/constraints.txt <<EOF
Django==3.0.9 ; python_version >= "3.6"
Django==2.2.15 ; python_version < "3.6"
EOF

cd /opt/python
for PYTHON in *; do
    echo
    echo $PYTHON
    $PYTHON/bin/python -m venv /venv-$PYTHON
    . /venv-$PYTHON/bin/activate
    pip install -q -U pip
    pip install -q -U "pip @ https://github.com/pypa/pip/archive/master.zip"
    pip install --use-feature 2020-resolver --constraint /constraints.txt Django
done

Then run it in a manylinux container with Docker or Podman:

podman run \
  -v /tmp/pip-issue-8724.sh:/test.sh:Z \
  quay.io/pypa/manylinux2014_x86_64 \
  bash /test.sh

For me this outputs:

cp35-cp35m
Cache entry deserialization failed, entry ignored
ERROR: Could not find a version that satisfies the requirement Django
ERROR: No matching distribution found for Django

cp36-cp36m
ERROR: Could not find a version that satisfies the requirement Django
ERROR: No matching distribution found for Django

cp37-cp37m
ERROR: Could not find a version that satisfies the requirement Django
ERROR: No matching distribution found for Django

cp38-cp38
ERROR: Could not find a version that satisfies the requirement Django
ERROR: No matching distribution found for Django

cp39-cp39
ERROR: Could not find a version that satisfies the requirement Django
ERROR: No matching distribution found for Django

@uranusjr
Copy link
Member

uranusjr commented Aug 6, 2020

@uranusjr no, it works perfectly with -r.

Thanks! I think I have an idea what’s going on; we’re likely not excluding lines based on the markers when we process the constraints file.

@uranusjr uranusjr added C: new resolver type: bug A confirmed bug or unintended behavior labels Aug 7, 2020
@triage-new-issues triage-new-issues bot removed the S: needs triage Issues/PRs that need to be triaged label Aug 7, 2020
@uranusjr uranusjr added this to the 20.2.2 milestone Aug 7, 2020
bors bot referenced this issue in duckinator/emanate Aug 11, 2020
162: Update pip to 20.2.2 r=duckinator a=pyup-bot


This PR updates [pip](https://pypi.org/project/pip) from **20.2.1** to **20.2.2**.



<details>
  <summary>Changelog</summary>
  
  
   ### 20.2.2
   ```
   ===================

Bug Fixes
---------

- Only attempt to use the keyring once and if it fails, don&#39;t try again.
  This prevents spamming users with several keyring unlock prompts when they
  cannot unlock or don&#39;t want to do so. (`8090 &lt;https://github.com/pypa/pip/issues/8090&gt;`_)
- Fix regression that distributions in system site-packages are not correctly
  found when a virtual environment is configured with ``system-site-packages``
  on. (`8695 &lt;https://github.com/pypa/pip/issues/8695&gt;`_)
- Disable caching for range requests, which causes corrupted wheels
  when pip tries to obtain metadata using the feature ``fast-deps``. (`8701 &lt;https://github.com/pypa/pip/issues/8701&gt;`_, `8716 &lt;https://github.com/pypa/pip/issues/8716&gt;`_)
- Always use UTF-8 to read ``pyvenv.cfg`` to match the built-in ``venv``. (`8717 &lt;https://github.com/pypa/pip/issues/8717&gt;`_)
- 2020 Resolver: Correctly handle marker evaluation in constraints and exclude
  them if their markers do not match the current environment. (`8724 &lt;https://github.com/pypa/pip/issues/8724&gt;`_)
   ```
   
  
</details>


 

<details>
  <summary>Links</summary>
  
  - PyPI: https://pypi.org/project/pip
  - Changelog: https://pyup.io/changelogs/pip/
  - Homepage: https://pip.pypa.io/
</details>



Co-authored-by: pyup-bot <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants