Skip to content

environment markers for different versions of same package override each other #518

@anthrotype

Description

@anthrotype

I have a requirements.in file which lists the same package twice, each time using a different environment marker. For python 2.7, I want to pin the version to the last python2-supported one; whereas for python 3 and above, I want to install the current version (which is python3 only).

Now, when I use pip to install from such an abstract requirements.in file, it manages to correctly read the different environment markers, and will install the pinned version on python 2.7 and the latest one on python 3.

However, if I use pip-compile the resulting requirements.txt has wrong version specifier and environment markers.

Here is the content of requirements.in:

$ cat requirements.in
doit==0.29.0 ; python_version=='2.7'
doit>=0.29.0 ; python_version>='3'

And here is the output from pip-compile:

$ pip-compile
#
# This file is autogenerated by pip-compile
# To update, run:
#
#    pip-compile --output-file requirements.txt requirements.in
#
--extra-index-url https://pypi.daltonmaag.com/simple/

cloudpickle==0.2.2        # via doit
doit==0.29.0 ; python_version >= "3"
macfsevents==0.7          # via doit
six==1.10.0               # via doit

You'll notice that doit is pinned to ==0.29.0 but it is followed by the wrong environment marker: it says ; python_version >= "3" but it should have been ; python_version == "2.7".
And the current doit version 0.30.3 (as of 29 May 2017) is not listed for python_version >= "3".

The expected output should have been:

cloudpickle==0.2.2        # via doit
doit==0.29.0 ; python_version == "2.7"
doit==0.30.3 ; python_version >= "3"
macfsevents==0.7          # via doit
six==1.10.0               # via doit

I get the same result - doit==0.29.0 ; python_version >= "3" - whether I run pip-compile from python 3.6.1 or from python 2.7.13.

I haven't looked at the code yet, but it looks like the environment marker of the last defined package with a given name overrides previous ones; whereas for the version specifiers, the first one for a given package name holds even if subsequently redefined.

I wonder if there are plans to support this kind of behavior in pip-compile?

Thank you in advance.

Related issues and PRs:

Environment Versions
  1. OS Type: MacOS 10.10.5
  2. Python version: 3.6.1
  3. pip version: 9.0.1
  4. pip-tools version: 1.9.1.dev15+gcd14543

Metadata

Metadata

Assignees

No one assigned

    Labels

    PR wantedFeature is discussed or bug is confirmed, PR neededbugSomething is not workingmarkersRelated to environment markers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions