Skip to content

Sync raises IncompatibleRequirements even when environment markers indicate the incompatible requirements to be irrelevant for the current platform #925

@AndydeCleyre

Description

@AndydeCleyre

IMO this is simply more of #206, and I've already demonstrated the problem there. But it's been a month and no one has re-opened, so I'm opening this more specific issue to address the problem.

Here's an example dev-requirements.txt from the plumbum project:

pytest
pytest-cov
pytest-mock
idna<2.8 ; python_version < '2.7'
pycparser<2.18 ; python_version < '2.7'
paramiko<2.4 ; python_version < '2.7'
paramiko ; python_version >= '2.7'
setuptools
wheel ; python_version >= '2.7'
psutil
pip-sync dev-requirements.txt

Identical output whether in a Python 3.7.4 or 2.7.16 env:

Incompatible requirements found: paramiko (from -r dev-requirements.txt (line 7)) and paramiko<2.4 (from -r dev-requirements.txt (line 6))

No packages end up installed aside from pip-tools and its deps.

Environment Versions

  1. Arch Linux
  2. Python version: 3.7.4
  3. pip version: 19.2.3
  4. pip-tools version: 4.1.0

Steps to replicate

echo "paramiko==2.4.0 ; python_version < '2.7'" > mark.txt
echo "paramiko==2.6.0 ; python_version >= '2.7'" >> mark.txt
pip-sync mark.txt

Note that this works:

pip install --no-deps -r mark.txt

Expected result

pip-sync should ignore non-matching requirements when environment markers are present.

Actual result

pip-sync checks for conflicts as if it wants to install requirements for all platforms.

Further notes

mv mark.txt mark.in
pip-compile --no-header mark.in
asn1crypto==1.0.1         # via cryptography
bcrypt==3.1.7             # via paramiko
cffi==1.12.3              # via bcrypt, cryptography, pynacl
cryptography==2.7         # via paramiko
paramiko==2.6.0 ; python_version >= "2.7"
pycparser==2.19           # via cffi
pynacl==1.3.0             # via paramiko
six==1.12.0               # via bcrypt, cryptography, pynacl

Currently, compiling such an in-file will only include the compile-time platform's matching reqs. This hides the issue under discussion, and arguably means it's not a bug. But I believe it is generally desired for pip-sync to honor environment markers, as evidenced by the contents of #206 (closed, but not solved), #600 (merged), #459 (replaced), #460 (merged), #518 (open 2yrs), #563 (open 2yrs), #585 (open 2yrs), #896 (open), etc.

This is probably even more relevant for working with a single python version across different platforms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprovements to functionalityneeds discussionNeed some more discussion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions