Repository: python-poetry/poetry

Issue:
PEP 508 URL dependencies
<!--
  Hi there! Thank you for wanting to make Poetry better.

  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 have searched the [issues](https://github.com/sdispater/poetry/issues) of this repo and believe that this is not a duplicate.
- [x] I have searched the [documentation](https://poetry.eustace.io/docs/) and believe that my question is not covered.

## Feature Request
<!-- Now feel free to write your idea for improvement. Thanks again 🙌 ❤️ -->

Hi, I'am trying to switch to poetry in our company but I have problem with [PEP 508](https://www.python.org/dev/peps/pep-0508/) URL requirements. We don't host private pypi repo but we are using git dependencies only. Imagine we have two libraries and project. The first library is for example _corp-utils_ and the sencond is _audit_. And _audit_ has dependency on _corp-utils_ in `setup.py`:
```
install_requires=[
    'django',
    ...
    'corp-utils @ git+ssh://git@corp-gitlab.com/corp-utils.git@1.2',
]
```
Then we have _audit_ in `pyproject.toml` on the project side:

```
[tool.poetry.dependencies]
python = "~3.5"
audit = {git = "ssh://git@corp-gitlab.com/audit.git", rev = "master"}

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
```

When I have tried `poetry lock`:
```
[SolverProblemError]
Because no versions of audit match !=1.40
 and audit (1.40) depends on corp-utils (*), every version of audit requires corp-utils (*).
So, because no versions of corp-utils match *
 and project depends on audit (*), version solving failed.
```

Next, I was experimenting with `setup.py` of the _audit_ library and found out that poetry is maybe ignoring the URL completely which could be dangerous. If I have changed `corp-utils` to `django-utils` which exists on [pypi](https://pypi.org/project/django-utils/) then the lock passed.

```
install_requires=[
    'django',
    ...
    'django-utils @ git+ssh://git@corp-gitlab.com/corp-utils.git@1.2',
]
```
But it resolved the pypi package instead of our package from git URL:
```
[[package]]
category = "main"
description = "Utilities for Django"
name = "django-utils"
optional = false
python-versions = "*"
version = "0.0.2"

...

[metadata]
content-hash = "35f83e7fbfc623c1a092cff7e4b3304b1d30daf0fd10e798b40bc723dbad1860"
python-versions = "~3.5"

[metadata.files]
...
django-utils = [
    {file = "django-utils-0.0.2.tar.gz", hash = "sha256:98b59b368d499b4d1b6dc66f15c0a136833bea12e0b299efdbfd754dc04c79d5"},
]
```
Is that desired behaviour or unsupported feature?

References:
https://pip.pypa.io/en/stable/news/#id189
https://stackoverflow.com/a/53706140/1763888



Discussion:
Could you test with the `1.0.0b6` version?
I have and result is same :/
I have also created dummy reproducible example:

[Library with git dependency](https://github.com/petrprikryl/test-poetry/blob/master/setup.py#L17)
[pyproject.toml](https://github.com/petrprikryl/test-poetry/blob/master/project/pyproject.toml#L9)
[Resulting lock](https://github.com/petrprikryl/test-poetry/blob/master/project/poetry.lock#L22)

`$ poetry lock -vvv`
```
Using virtualenv: /....../.venv
Updating dependencies
Resolving dependencies...
   1: fact: project is 0.1.0
   1: derived: project
   1: fact: project depends on audit (*)
   1: selecting project (0.1.0)
   1: derived: audit (*)
   1: fact: audit (1.0.0) depends on django (*)
   1: selecting audit (1.0.0 90828c0)
   1: derived: django (*)
PyPI: No release information found for django-1.1.2, skipping
PyPI: No release information found for django-1.0.3, skipping
PyPI: No release information found for django-1.0.2, skipping
PyPI: No release information found for django-1.0.1, skipping
PyPI: No release information found for django-1.0.4, skipping
PyPI: No release information found for django-1.1.1, skipping
PyPI: No release information found for django-1.1, skipping
PyPI: 182 packages found for django *
   1: fact: django (2.2.7) depends on pytz (*)
   1: fact: django (2.2.7) depends on sqlparse (*)
   1: selecting django (2.2.7)
   1: derived: sqlparse (*)
   1: derived: pytz (*)
PyPI: 26 packages found for sqlparse *
PyPI: 82 packages found for pytz *
   1: selecting sqlparse (0.3.0)
   1: selecting pytz (2019.3)
   1: Version solving took 2.539 seconds.
   1: Tried 1 solutions.
```
`$ poetry install`
```
Installing dependencies from lock file


Package operations: 2 installs, 1 update, 0 removals

  - Installing sqlparse (0.3.0)
  - Updating django (2.1.14 -> 2.2.7)
  - Installing audit (1.0.0 90828c0)
```
So here we can see that poetry didn't resolve forked Django and branch _support-1.11.13_. But locked to newest pypi Django 2.2.7.

Resolving patch:
diff --git a/poetry/packages/__init__.py b/poetry/packages/__init__.py
--- a/poetry/packages/__init__.py
+++ b/poetry/packages/__init__.py
@@ -25,6 +25,8 @@
 
 
 def dependency_from_pep_508(name):
+    from poetry.vcs.git import ParsedUrl
+
     # Removing comments
     parts = name.split("#", 1)
     name = parts[0].strip()
@@ -46,6 +48,8 @@ def dependency_from_pep_508(name):
 
     if is_url(name):
         link = Link(name)
+    elif req.url:
+        link = Link(req.url)
     else:
         p, extras = strip_extras(path)
         if os.path.isdir(p) and (os.path.sep in name or name.startswith(".")):
@@ -74,10 +78,15 @@ def dependency_from_pep_508(name):
             version = m.group("ver")
             dep = Dependency(name, version)
         else:
-            name = link.egg_fragment
+            name = req.name or link.egg_fragment
 
-            if link.scheme == "git":
+            if link.scheme.startswith("git+"):
+                url = ParsedUrl.parse(link.url)
+                dep = VCSDependency(name, "git", url.url, rev=url.rev)
+            elif link.scheme == "git":
                 dep = VCSDependency(name, "git", link.url_without_fragment)
+            elif link.scheme in ["http", "https"]:
+                dep = URLDependency(name, link.url_without_fragment)
             else:
                 dep = Dependency(name, "*")
     else:
diff --git a/poetry/vcs/git.py b/poetry/vcs/git.py
--- a/poetry/vcs/git.py
+++ b/poetry/vcs/git.py
@@ -78,16 +78,19 @@ def parse(cls, url):  # type: () -> ParsedUrl
 
         raise ValueError('Invalid git url "{}"'.format(url))
 
-    def format(self):
+    @property
+    def url(self):  # type: () -> str
         return "{}{}{}{}{}".format(
             "{}://".format(self.protocol) if self.protocol else "",
             "{}@".format(self.user) if self.user else "",
             self.resource,
             ":{}".format(self.port) if self.port else "",
             "/" + self.pathname if self.pathname.startswith(":") else self.pathname,
-            "#{}".format(self.rev) if self.rev else "",
         )
 
+    def format(self):
+        return "{}".format(self.url, "#{}".format(self.rev) if self.rev else "",)
+
     def __str__(self):  # type: () -> str
         return self.format()
 
diff --git a/poetry/version/requirements.py b/poetry/version/requirements.py
--- a/poetry/version/requirements.py
+++ b/poetry/version/requirements.py
@@ -28,7 +28,7 @@
 try:
     import urllib.parse as urlparse
 except ImportError:
-    from urlparse import urlparse
+    import urlparse
 
 
 LEGACY_REGEX = r"""


Test patch:
diff --git a/tests/packages/test_main.py b/tests/packages/test_main.py
--- a/tests/packages/test_main.py
+++ b/tests/packages/test_main.py
@@ -169,3 +169,25 @@ def test_dependency_from_pep_508_with_not_in_op_marker():
     assert (
         str(dep.marker) == 'python_version not in "3.0,3.1,3.2" and extra == "export"'
     )
+
+
+def test_dependency_from_pep_508_with_git_url():
+    name = "django-utils @ git+ssh://git@corp-gitlab.com/corp-utils.git@1.2"
+
+    dep = dependency_from_pep_508(name)
+
+    assert "django-utils" == dep.name
+    assert dep.is_vcs()
+    assert "git" == dep.vcs
+    assert "ssh://git@corp-gitlab.com/corp-utils.git" == dep.source
+    assert "1.2" == dep.reference
+
+
+def test_dependency_from_pep_508_with_url():
+    name = "django-utils @ https://example.com/django-utils-1.0.0.tar.gz"
+
+    dep = dependency_from_pep_508(name)
+
+    assert "django-utils" == dep.name
+    assert dep.is_url()
+    assert "https://example.com/django-utils-1.0.0.tar.gz" == dep.url