Pip: [2020-resolver] Fails if two versions with `; python_version` in constraints for the same package

Created on 6 Aug 2020  路  4Comments  路  Source: pypa/pip

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



md5-f9f87c635ae10847a206afd95a1e8a1d



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
new resolver bug

Most helpful comment

@uranusjr no, it works perfectly with -r.

Thanks! I think I have an idea what鈥檚 going on; we鈥檙e likely not excluding lines based on the markers when we process the constraints file.

All 4 comments

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

@uranusjr no, it works perfectly with -r.

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 no, it works perfectly with -r.

Thanks! I think I have an idea what鈥檚 going on; we鈥檙e likely not excluding lines based on the markers when we process the constraints file.

Was this page helpful?
0 / 5 - 0 ratings