Repository: python-poetry/poetry

Issue:
Wheel Naming Discrepancy Prevents Installing
<!--
  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.
-->

- **OS version and name**: Linux
- **Poetry version**: Poetry 1.0.0a1
- **Link of a [Gist](https://gist.github.com/) with the contents of your pyproject.toml file**: <!-- Gist Link Here --> N/A

## Issue
<!-- Now feel free to write your issue, but please be descriptive! Thanks again 🙌 ❤️ -->

Building wheel packages with Poetry produces different version naming/wheel packages than `bdist_wheel` which is preventing other packages from finding it in our private index.

For example, our library package has a version set to:
```
name = "arroyo-settings"
version = "0+untagged.35.g68290c5"
```
When building it with Poetry it produces a wheel:
```
Building arroyo-settings (0+untagged.35.g68290c5)
 - Building wheel
 - Built arroyo_settings-0_untagged.35.g68290c5-py3-none-any.whl
```
When building with `setup.py bdist_wheel`:
```
arroyo_settings-0+untagged.35.g68290c5-py3-none-any.whl
```

Using the Poetry built wheel, trying to `poetry add arroyo-settings` in our second project, I get the following: https://gist.github.com/seglberg/e5521c49359ec276ac2a81c0b010af3e


Discussion:
Ah the version in the metadata wasn't transformed `0+untagged.35.g68290c5` (with the `+`) - which is probably causing the mismatch.
I see this issue as well when using poetry and devpi server - except the devpi server rejects the upload:

```sh
poetry publish --repository kristofferb_dev

Publishing my-package (0.1.3-dev0+some_branch) to kristofferb_dev
 - Uploading my-package-0.1.3.dev0+some.branch.tar.gz 100%
                                                                                                                                                                                       
[HTTPError]                                                                                                                                                             
400 Client Error: filename 'my-package-0.1.3.dev0_some.branch-py3-none-any.whl' does not contain version '0.1.3.dev0+some.branch' for url: https://<our devpi package index>/kristofferb/dev/ 
```

The issue seems to be the regex here

https://github.com/sdispater/poetry/blob/6fe7f54a83c59131d4e291084c3496a0c513cfaa/poetry/masonry/builders/wheel.py#L201

that replaces `+` with `_` in the wheel filename. 

Resolving patch:
diff --git a/poetry/masonry/builders/wheel.py b/poetry/masonry/builders/wheel.py
--- a/poetry/masonry/builders/wheel.py
+++ b/poetry/masonry/builders/wheel.py
@@ -203,7 +203,7 @@ def dist_info(self):  # type: () -> str
     def wheel_filename(self):  # type: () -> str
         return "{}-{}-{}.whl".format(
             re.sub(r"[^\w\d.]+", "_", self._package.pretty_name, flags=re.UNICODE),
-            re.sub(r"[^\w\d.]+", "_", self._meta.version, flags=re.UNICODE),
+            re.sub(r"[^\w\d.\+]+", "_", self._meta.version, flags=re.UNICODE),
             self.tag,
         )
 
@@ -214,7 +214,7 @@ def supports_python2(self):
 
     def dist_info_name(self, distribution, version):  # type: (...) -> str
         escaped_name = re.sub(r"[^\w\d.]+", "_", distribution, flags=re.UNICODE)
-        escaped_version = re.sub(r"[^\w\d.]+", "_", version, flags=re.UNICODE)
+        escaped_version = re.sub(r"[^\w\d.+]+", "_", version, flags=re.UNICODE)
 
         return "{}-{}.dist-info".format(escaped_name, escaped_version)
 


Test patch:
diff --git a/tests/masonry/builders/fixtures/localversionlabel/README.rst b/tests/masonry/builders/fixtures/localversionlabel/README.rst
new file mode 100644
--- /dev/null
+++ b/tests/masonry/builders/fixtures/localversionlabel/README.rst
@@ -0,0 +1,2 @@
+Local version label
+===================
diff --git a/tests/masonry/builders/fixtures/localversionlabel/localversionlabel.py b/tests/masonry/builders/fixtures/localversionlabel/localversionlabel.py
new file mode 100644
--- /dev/null
+++ b/tests/masonry/builders/fixtures/localversionlabel/localversionlabel.py
@@ -0,0 +1,3 @@
+"""Example module"""
+
+__version__ = "0.1"
diff --git a/tests/masonry/builders/fixtures/localversionlabel/pyproject.toml b/tests/masonry/builders/fixtures/localversionlabel/pyproject.toml
new file mode 100644
--- /dev/null
+++ b/tests/masonry/builders/fixtures/localversionlabel/pyproject.toml
@@ -0,0 +1,12 @@
+[tool.poetry]
+name = "localversionlabel"
+version = "0.1-beta.1+gitbranch-buildno-1"
+description = "Some description."
+authors = [
+    "Sébastien Eustace <sebastien@eustace.io>"
+]
+license = "MIT"
+
+readme = "README.rst"
+
+homepage = "https://poetry.eustace.io/"
diff --git a/tests/masonry/builders/test_wheel.py b/tests/masonry/builders/test_wheel.py
--- a/tests/masonry/builders/test_wheel.py
+++ b/tests/masonry/builders/test_wheel.py
@@ -61,6 +61,18 @@ def test_wheel_prerelease():
     assert whl.exists()
 
 
+def test_wheel_localversionlabel():
+    module_path = fixtures_dir / "localversionlabel"
+    WheelBuilder.make(Poetry.create(str(module_path)), NullEnv(), NullIO())
+    local_version_string = "localversionlabel-0.1b1+gitbranch.buildno.1"
+    whl = module_path / "dist" / (local_version_string + "-py2.py3-none-any.whl")
+
+    assert whl.exists()
+
+    with zipfile.ZipFile(str(whl)) as z:
+        assert local_version_string + ".dist-info/METADATA" in z.namelist()
+
+
 def test_wheel_package_src():
     module_path = fixtures_dir / "source_package"
     WheelBuilder.make(Poetry.create(str(module_path)), NullEnv(), NullIO())