Repository: python-poetry/poetry

Issue:
Conflicting dependences where different Python versions are specified.   Because usignals depends on both ipython (^5) and ipython (^7), version solving failed.
- [X] I am on the [latest](https://github.com/sdispater/poetry/releases/latest) Poetry version.
- [X] I have searched the [issues](https://github.com/sdispater/poetry/issues) of this repo and believe that this is not a duplicate.
- [X] If an exception occurs when executing a command, I executed it again in debug mode (`-vvv` option).


- **OS version and name**: CentOS 7, Python 3.7.4
- **Poetry version**: 0.12.17
- **Link of a [Gist](https://gist.github.com/) with the contents of your pyproject.toml file**: <!-- Gist Link Here -->

## Issue

I have this so that my module works on either 2.7 or 3.7 and in `pyproject.toml`, I specified:

```
[tool.poetry.dependencies]
python = "^2.7 || ^3.7"  # ← Run on either 2.7 or 3.7???
[…]
[tool.poetry.dev-dependencies]
ipython = [
    {version = "^5", python = "~2.7"},  # ← Install version 5 under py2.7???
    {version = "^7", python = ">=3.5"}  # ← Install version 7.8 under py37???
]
```

Which I assume means that I want ipython version 5 for 2.7 and ipython version 7 for any python above 3.5. However, what I get is:

```
poetry -vvv debug:resolve
Resolving dependencies...
[…]
   1: fact: usignals depends on ipython (^5)
   1: fact: usignals depends on ipython (^7)
[…]
   1: derived: ipython (^7.8)
   1: conflict: usignals depends on ipython (^5)
   1: ! not ipython (^5) is satisfied by ipython (^7)
   1: ! which is caused by "usignals depends on ipython (^7)"
   1: ! thus: version solving failed
   1: Version solving took 0.016 seconds.
   1: Tried 1 solutions.
```

_Is this a bug or did I misunderstand something?_


Discussion:

Resolving patch:
diff --git a/poetry/puzzle/provider.py b/poetry/puzzle/provider.py
--- a/poetry/puzzle/provider.py
+++ b/poetry/puzzle/provider.py
@@ -534,8 +534,8 @@ def complete_package(
     ):  # type: (DependencyPackage) -> DependencyPackage
         if package.is_root():
             package = package.clone()
-
-        if not package.is_root() and package.source_type not in {
+            requires = package.all_requires
+        elif not package.is_root() and package.source_type not in {
             "directory",
             "file",
             "url",
@@ -550,10 +550,13 @@ def complete_package(
                     repository=package.dependency.source_name,
                 ),
             )
+            requires = package.requires
+        else:
+            requires = package.requires
 
         dependencies = [
             r
-            for r in package.requires
+            for r in requires
             if self._package.python_constraint.allows_any(r.python_constraint)
         ]
 
@@ -582,6 +585,8 @@ def complete_package(
 
             duplicates[dep.name].append(dep)
 
+        print(package)
+        print(duplicates)
         dependencies = []
         for dep_name, deps in duplicates.items():
             if len(deps) == 1:


Test patch:
diff --git a/tests/puzzle/test_solver.py b/tests/puzzle/test_solver.py
--- a/tests/puzzle/test_solver.py
+++ b/tests/puzzle/test_solver.py
@@ -1811,3 +1811,27 @@ def test_solver_discards_packages_with_empty_markers(
             {"job": "install", "package": package_a},
         ],
     )
+
+
+def test_solver_does_not_raise_conflict_for_conditional_dev_dependencies(
+    solver, repo, package
+):
+    package.python_versions = "~2.7 || ^3.5"
+    package.add_dependency("A", {"version": "^1.0", "python": "~2.7"}, category="dev")
+    package.add_dependency("A", {"version": "^2.0", "python": "^3.5"}, category="dev")
+
+    package_a100 = get_package("A", "1.0.0")
+    package_a200 = get_package("A", "2.0.0")
+
+    repo.add_package(package_a100)
+    repo.add_package(package_a200)
+
+    ops = solver.solve()
+
+    check_solver_result(
+        ops,
+        [
+            {"job": "install", "package": package_a100},
+            {"job": "install", "package": package_a200},
+        ],
+    )