Repository: python-poetry/poetry

Issue:
poetry v1.0.0b4 breaks on zip packages
<!-- 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).

- **OS version and name**: Windows 10 with a virtual environment for Python v3.7.4
- **Poetry version**: 1.0.0b4
- **Link of a [Gist](https://gist.github.com/) with the contents of your pyproject.toml file**: (empty project)

## Issue Summary
The newly refactored distribution loading mechanism from [PR 1549](https://github.com/sdispater/poetry/pull/1549/) fails when a zip-based package is present. The presenting problem is that the `zipp.Path` class is not compatible with the `__fspath__` protocol.

## Issue Details
After updating to Poetry v1.0.0b4, I get this traceback

```
% poetry update -v
Using virtualenv: C:\Users\garyd\devel\video-storage\venv-new
[TypeError]
expected str, bytes or os.PathLike object, not Path
Traceback (most recent call last):
  File "C:\Users\garyd\.poetry\lib\poetry\_vendor\py3.7\clikit\console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "C:\Users\garyd\.poetry\lib\poetry\_vendor\py3.7\clikit\api\command\command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "C:\Users\garyd\.poetry\lib\poetry\_vendor\py3.7\clikit\api\command\command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "C:\Users\garyd\.poetry\lib\poetry\_vendor\py3.7\cleo\commands\command.py", line 92, in wrap_handle
    return self.handle()
  File "C:\Users\garyd\.poetry\lib\poetry\console\commands\update.py", line 36, in handle
    self.io, self.env, self.poetry.package, self.poetry.locker, self.poetry.pool
  File "C:\Users\garyd\.poetry\lib\poetry\installation\installer.py", line 55, in __init__
    installed = self._get_installed()
  File "C:\Users\garyd\.poetry\lib\poetry\installation\installer.py", line 507, in _get_installed
    return InstalledRepository.load(self._env)
  File "C:\Users\garyd\.poetry\lib\poetry\repositories\installed_repository.py", line 30, in load
    path = Path(distribution._path)
  File "C:\Users\garyd\AppData\Local\Programs\Python\Python37\lib\pathlib.py", line 1010, in __new__
    self = cls._from_parts(args, init=False)
```

When I run the broken part of the code in my console, I find that the broken distribution is:

* type == <class 'importlib_metadata.PathDistribution'>
* type(dist._path) == <class 'zipp.Path'>
* dist._path == C:\Users\garyd\devel\video-storage\venv\lib\site-packages\setuptools-40.8.0-py3.7.egg/EGG-INFO/




Discussion:

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
@@ -27,7 +27,7 @@ def load(cls, env):  # type: (Env) -> InstalledRepository
 
             repo.add_package(package)
 
-            path = Path(distribution._path)
+            path = Path(str(distribution._path))
             is_standard_package = True
             try:
                 path.relative_to(env.site_packages)


Test patch:
diff --git a/tests/repositories/fixtures/installed/lib/python3.7/site-packages/foo-0.1.0-py3.8.egg b/tests/repositories/fixtures/installed/lib/python3.7/site-packages/foo-0.1.0-py3.8.egg
new file mode 100644
Binary files /dev/null and b/tests/repositories/fixtures/installed/lib/python3.7/site-packages/foo-0.1.0-py3.8.egg differ
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
@@ -1,3 +1,5 @@
+import zipp
+
 from importlib_metadata import PathDistribution
 from poetry.repositories.installed_repository import InstalledRepository
 from poetry.utils._compat import Path
@@ -11,6 +13,7 @@
 INSTALLED_RESULTS = [
     PathDistribution(SITE_PACKAGES / "cleo-0.7.6.dist-info"),
     PathDistribution(SRC / "pendulum" / "pendulum.egg-info"),
+    PathDistribution(zipp.Path(str(SITE_PACKAGES / "foo-0.1.0-py3.8.egg"), "EGG-INFO")),
 ]
 
 
@@ -37,7 +40,7 @@ def test_load(mocker):
     )
     repository = InstalledRepository.load(MockEnv(path=ENV_DIR))
 
-    assert len(repository.packages) == 2
+    assert len(repository.packages) == 3
 
     cleo = repository.packages[0]
     assert cleo.name == "cleo"
@@ -47,7 +50,11 @@ def test_load(mocker):
         == "Cleo allows you to create beautiful and testable command-line interfaces."
     )
 
-    pendulum = repository.packages[1]
+    foo = repository.packages[1]
+    assert foo.name == "foo"
+    assert foo.version.text == "0.1.0"
+
+    pendulum = repository.packages[2]
     assert pendulum.name == "pendulum"
     assert pendulum.version.text == "2.0.5"
     assert pendulum.description == "Python datetimes made easy"