Repository: pypa/wheel

Issue:
How should a PEP 508 requirement with an URL specifier be handled?
Starting with pip 10.0, requirements with [URL specifiers](https://www.python.org/dev/peps/pep-0508/#examples) are now supported (as replacement for dependency links).

With the following sample project' `setup.py`:
```python
from setuptools import setup

setup(name='projecta', version='42',
      install_requires='''
      lazyImport@git+https://gitlab.com/KOLANICH1/lazyImport.py.git#egg=lazyImport-dev
      ''')
```

Installing from source work, but looking at the generated wheel metadata:
```shell
> python setup.py -q bdist_wheel && unzip -p dist/projecta-42-py3-none-any.whl '*/METADATA'
Metadata-Version: 2.1
Name: projecta
Version: 42
Summary: Description!
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Platform: UNKNOWN
Requires-Dist: lazyImport

UNKNOWN
```

It works with the following patch:
```diff
 tests/test_metadata.py | 3 +++
 wheel/metadata.py      | 2 ++
 2 files changed, 5 insertions(+)

diff --git i/tests/test_metadata.py w/tests/test_metadata.py
index 3421430..2390e98 100644
--- i/tests/test_metadata.py
+++ w/tests/test_metadata.py
@@ -9,6 +9,7 @@ def test_pkginfo_to_metadata(tmpdir):
         ('Provides-Extra', 'test'),
         ('Provides-Extra', 'signatures'),
         ('Provides-Extra', 'faster-signatures'),
+        ('Requires-Dist', "pip @ https://github.com/pypa/pip/archive/1.3.1.zip"),
         ('Requires-Dist', "ed25519ll; extra == 'faster-signatures'"),
         ('Requires-Dist', "keyring; extra == 'signatures'"),
         ('Requires-Dist', "keyrings.alt; extra == 'signatures'"),
@@ -28,6 +29,8 @@ def test_pkginfo_to_metadata(tmpdir):
 
     egg_info_dir = tmpdir.ensure_dir('test.egg-info')
     egg_info_dir.join('requires.txt').write("""\
+pip@ https://github.com/pypa/pip/archive/1.3.1.zip
+
 [faster-signatures]
 ed25519ll
 
diff --git i/wheel/metadata.py w/wheel/metadata.py
index 4fa17cd..5b03e3e 100644
--- i/wheel/metadata.py
+++ w/wheel/metadata.py
@@ -17,6 +17,8 @@
 
 def requires_to_requires_dist(requirement):
     """Compose the version predicates for requirement in PEP 345 fashion."""
+    if requirement.url:
+        return " @ " + requirement.url
     requires_dist = []
     for op, ver in requirement.specs:
         requires_dist.append(op + ver)
```

```shell
> python setup.py -q bdist_wheel && unzip -p dist/projecta-42-py3-none-any.whl '*/METADATA'
Metadata-Version: 2.1
Name: projecta
Version: 42
Summary: Description!
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Platform: UNKNOWN
Requires-Dist: lazyImport @ git+https://gitlab.com/KOLANICH1/lazyImport.py.git

UNKNOWN
```

Unfortunately, this is technically not valid [PEP 345](https://www.python.org/dev/peps/pep-0345/#requires-dist-multiple-use) metadata.

Comments:

Patch:
diff --git a/wheel/metadata.py b/wheel/metadata.py
index 4fa17cd..c6a3736 100644
--- a/wheel/metadata.py
+++ b/wheel/metadata.py
@@ -16,7 +16,10 @@ EXTRA_RE = re.compile("""^(?P<package>.*?)(;\s*(?P<condition>.*?)(extra == '(?P<
 
 
 def requires_to_requires_dist(requirement):
-    """Compose the version predicates for requirement in PEP 345 fashion."""
+    """Return the version specifier for a requirement in PEP 345/566 fashion."""
+    if requirement.url:
+        return " @ " + requirement.url
+
     requires_dist = []
     for op, ver in requirement.specs:
         requires_dist.append(op + ver)


Test patch:
diff --git a/tests/test_metadata.py b/tests/test_metadata.py
index 3421430..78fe40d 100644
--- a/tests/test_metadata.py
+++ b/tests/test_metadata.py
@@ -9,6 +9,7 @@ def test_pkginfo_to_metadata(tmpdir):
         ('Provides-Extra', 'test'),
         ('Provides-Extra', 'signatures'),
         ('Provides-Extra', 'faster-signatures'),
+        ('Requires-Dist', "pip @ https://github.com/pypa/pip/archive/1.3.1.zip"),
         ('Requires-Dist', "ed25519ll; extra == 'faster-signatures'"),
         ('Requires-Dist', "keyring; extra == 'signatures'"),
         ('Requires-Dist', "keyrings.alt; extra == 'signatures'"),
@@ -28,6 +29,8 @@ Provides-Extra: faster-signatures""")
 
     egg_info_dir = tmpdir.ensure_dir('test.egg-info')
     egg_info_dir.join('requires.txt').write("""\
+pip@https://github.com/pypa/pip/archive/1.3.1.zip
+
 [faster-signatures]
 ed25519ll