Repository: pypa/pip

Issue:
Development version number triggers a false positive warning
* Pip version: 10.0.0b1
* Python version: 3.6.4
* Operating system: Linux

### Description:

Say a package `foo` depends on `bar>=1.0.0`. If the installed version of `bar` is a development version such as `1.0.1.dev42`, pip issues an incompatible version warning upon installation of `foo`. Pip shouldn't issue any warning since `1.0.1.dev42>=1.0.0`. The weird thing is that pip is satisfied with that version when scanning the dependencies of `foo`, but issues that warning anyway.

For that matter, the real life scenario is installing a development library with a `setuptools_scm`-generated version number and then installing a library that depends on it.

### What I've run:

```
% tree
.
├── bar
│   └── setup.py
└── foo
    └── setup.py

2 directories, 2 files
```

```
% cat bar/setup.py
from setuptools import setup

setup(
    name='bar',
    version='1.0.1.dev42')
```

```
% cat foo/setup.py
from setuptools import setup

setup(
    name='foo',
    install_requires=['bar>=1.0.0'],
    version='3.14.15')
```

```
# setting up virtual environment
% python3 -m venv compat
% source compat/bin/activate
% pip install pip==10.0.0b1
```

```
% pip install ./bar
Processing ./bar
Installing collected packages: bar
  Running setup.py install for bar ... done
Successfully installed bar-1.0.1.dev42
```

```
% pip install ./foo
Processing ./foo
Requirement already satisfied: bar>=1.0.0 in ./compat/lib/python3.6/site-packages (from foo==3.14.15) (1.0.1.dev42)
foo 3.14.15 has requirement bar>=1.0.0, but you'll have bar 1.0.1.dev42 which is incompatible.
Installing collected packages: foo
  Running setup.py install for foo ... done
Successfully installed foo-3.14.15
```



Discussion:
@pradyunsg is probably the best person to take a look at this.
I'll take a look tonight.

Resolving patch:
diff --git a/src/pip/_internal/operations/check.py b/src/pip/_internal/operations/check.py
--- a/src/pip/_internal/operations/check.py
+++ b/src/pip/_internal/operations/check.py
@@ -63,7 +63,7 @@ def check_package_set(package_set):
 
             # Check if there's a conflict
             version = package_set[name].version  # type: str
-            if version not in req.specifier:
+            if not req.specifier.contains(version, prereleases=True):
                 conflicting_deps.add((name, version, req))
 
         def str_key(x):


Test patch:
diff --git a/tests/functional/test_check.py b/tests/functional/test_check.py
--- a/tests/functional/test_check.py
+++ b/tests/functional/test_check.py
@@ -193,3 +193,32 @@ def test_check_considers_conditional_reqs(script):
     )
     assert matches_expected_lines(result.stdout, expected_lines)
     assert result.returncode == 1
+
+
+def test_check_development_versions_are_also_considered(script):
+    # Setup pkga depending on pkgb>=1.0
+    pkga_path = create_test_package_with_setup(
+        script,
+        name='pkga', version='1.0', install_requires=['depend>=1.0'],
+    )
+    # Let's install pkga without its dependency
+    res = script.pip('install', '--no-index', pkga_path, '--no-deps')
+    assert "Successfully installed pkga-1.0" in res.stdout, str(res)
+
+    # Setup depend==1.1.0.dev0
+    depend_path = create_test_package_with_setup(
+        script,
+        name='depend', version='1.1.0.dev0',
+    )
+    # Let's install depend==1.1.0.dev0
+    res = script.pip(
+        'install', '--no-index', depend_path, '--no-warn-conflicts',
+    )
+    assert "Successfully installed depend-1.1.0.dev0" in res.stdout, str(res)
+
+    result = script.pip('check')
+    expected_lines = (
+        "No broken requirements found.",
+    )
+    assert matches_expected_lines(result.stdout, expected_lines)
+    assert result.returncode == 0