-
-
Notifications
You must be signed in to change notification settings - Fork 628
Description
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:
- add support for environment markers in requirements lines for pip-sync #206
- #206: Preserve environment markers from requirements.in #460
Environment Versions
- OS Type: MacOS 10.10.5
- Python version: 3.6.1
- pip version: 9.0.1
- pip-tools version: 1.9.1.dev15+gcd14543