Repository: python-poetry/poetry

Issue:
Arbitrary equality in pip freeze causes crash
<!--
  Hi there! Thank you for discovering and submitting an issue.

  Before you submit this; let's make sure of a few things.
  Please make sure the following boxes are ticked if they are correct.
  If not, please try and fulfill these first.
-->

<!-- Checked checkbox should look like this: [x] -->
- [ 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).

<!--
  Once those are done, if you're able to fill in the following list with your information,
  it'd be very helpful to whoever handles the issue.
-->

- **MacOS High Sierra 10.13.6**: <!-- Replace with version + name -->
- **Poetry 0.11.5**: <!-- Replace with version -->

## Issue
<!-- Now feel free to write your issue, but please be descriptive! Thanks again 🙌 ❤️ -->
Running `poetry install` when a package is installed such that pip freeze lists it with an arbitrary equality operator (ex. `package===1.6.1-642-g1e03d5e853`) causes an exception

```
[ValueError]
Unable to parse "=1.6.1-642-g1e03d5e853".
```

Looks like the issue is the strict splitting on `==` in `poetry/repositories/installed_repository.py`.



Discussion:
Maybe change `name, version = line.split("==")` to `name, version = re.split("={2,3}", line)`?

Resolving patch:
diff --git a/poetry/repositories/installed_repository.py b/poetry/repositories/installed_repository.py
--- a/poetry/repositories/installed_repository.py
+++ b/poetry/repositories/installed_repository.py
@@ -1,3 +1,5 @@
+import re
+
 from poetry.packages import Package
 from poetry.utils.env import Env
 
@@ -17,7 +19,7 @@ def load(cls, env):  # type: (Env) -> InstalledRepository
         freeze_output = env.run("pip", "freeze")
         for line in freeze_output.split("\n"):
             if "==" in line:
-                name, version = line.split("==")
+                name, version = re.split("={2,3}", line)
                 repo.add_package(Package(name, version, version))
             elif line.startswith("-e "):
                 line = line[3:].strip()


Test patch:
diff --git a/tests/repositories/test_installed_repository.py b/tests/repositories/test_installed_repository.py
--- a/tests/repositories/test_installed_repository.py
+++ b/tests/repositories/test_installed_repository.py
@@ -4,6 +4,7 @@
 
 FREEZE_RESULTS = """cleo==0.6.8
 -e git+https://github.com/sdispater/pendulum.git@bb058f6b78b2d28ef5d9a5e759cfa179a1a713d6#egg=pendulum
+orator===0.9.8
 """
 
 
@@ -18,7 +19,7 @@ def run(self, bin, *args):
 def test_load():
     repository = InstalledRepository.load(MockEnv())
 
-    assert len(repository.packages) == 2
+    assert len(repository.packages) == 3
 
     cleo = repository.packages[0]
     assert cleo.name == "cleo"
@@ -30,3 +31,7 @@ def test_load():
     assert pendulum.source_type == "git"
     assert pendulum.source_url == "https://github.com/sdispater/pendulum.git"
     assert pendulum.source_reference == "bb058f6b78b2d28ef5d9a5e759cfa179a1a713d6"
+
+    orator = repository.packages[2]
+    assert orator.name == "orator"
+    assert orator.version.text == "0.9.8"