diff --git a/poetry/masonry/builders/wheel.py b/poetry/masonry/builders/wheel.py index cdba38c51e3..9482c647967 100644 --- a/poetry/masonry/builders/wheel.py +++ b/poetry/masonry/builders/wheel.py @@ -183,9 +183,20 @@ def _write_metadata(self, wheel): with self._write_to_zip(wheel, self.dist_info + "/entry_points.txt") as f: self._write_entry_points(f) + license_files_to_add = [] for base in ("COPYING", "LICENSE"): - for path in sorted(self._path.glob(base + "*")): - self._add_file(wheel, path, "%s/%s" % (self.dist_info, path.name)) + license_files_to_add.append(self._path / base) + license_files_to_add.extend(self._path.glob(base + ".*")) + + license_files_to_add.extend((self._path / "LICENSES").glob("**" + os.sep + "*")) + + for path in license_files_to_add: + if not path.is_file(): + continue + + self._add_file( + wheel, path, "%s/%s" % (self.dist_info, path.relative_to(self._path)) + ) with self._write_to_zip(wheel, self.dist_info + "/WHEEL") as f: self._write_wheel_file(f) diff --git a/tests/masonry/builders/fixtures/licenses_and_copying/COPYING b/tests/masonry/builders/fixtures/licenses_and_copying/COPYING new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/masonry/builders/fixtures/licenses_and_copying/COPYING.txt b/tests/masonry/builders/fixtures/licenses_and_copying/COPYING.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/masonry/builders/fixtures/licenses_and_copying/LICENSE b/tests/masonry/builders/fixtures/licenses_and_copying/LICENSE new file mode 100644 index 00000000000..44cf2b30e68 --- /dev/null +++ b/tests/masonry/builders/fixtures/licenses_and_copying/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2018 Sébastien Eustace + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tests/masonry/builders/fixtures/licenses_and_copying/LICENSE.md b/tests/masonry/builders/fixtures/licenses_and_copying/LICENSE.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/masonry/builders/fixtures/licenses_and_copying/LICENSES/BSD-3.md b/tests/masonry/builders/fixtures/licenses_and_copying/LICENSES/BSD-3.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/masonry/builders/fixtures/licenses_and_copying/LICENSES/CUSTOM-LICENSE b/tests/masonry/builders/fixtures/licenses_and_copying/LICENSES/CUSTOM-LICENSE new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/masonry/builders/fixtures/licenses_and_copying/LICENSES/MIT.txt b/tests/masonry/builders/fixtures/licenses_and_copying/LICENSES/MIT.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/masonry/builders/fixtures/licenses_and_copying/README.rst b/tests/masonry/builders/fixtures/licenses_and_copying/README.rst new file mode 100644 index 00000000000..f7fe15470f9 --- /dev/null +++ b/tests/masonry/builders/fixtures/licenses_and_copying/README.rst @@ -0,0 +1,2 @@ +My Package +========== diff --git a/tests/masonry/builders/fixtures/licenses_and_copying/my_package/__init__.py b/tests/masonry/builders/fixtures/licenses_and_copying/my_package/__init__.py new file mode 100644 index 00000000000..10aa336ce07 --- /dev/null +++ b/tests/masonry/builders/fixtures/licenses_and_copying/my_package/__init__.py @@ -0,0 +1 @@ +__version__ = "1.2.3" diff --git a/tests/masonry/builders/fixtures/licenses_and_copying/pyproject.toml b/tests/masonry/builders/fixtures/licenses_and_copying/pyproject.toml new file mode 100644 index 00000000000..b56bbe63758 --- /dev/null +++ b/tests/masonry/builders/fixtures/licenses_and_copying/pyproject.toml @@ -0,0 +1,49 @@ +[tool.poetry] +name = "my-package" +version = "1.2.3" +description = "Some description." +authors = [ + "Sébastien Eustace " +] +maintainers = [ + "People Everywhere " +] +license = "MIT" + +readme = "README.rst" + +homepage = "https://python-poetry.org/" +repository = "https://github.com/python-poetry/poetry" +documentation = "https://python-poetry.org/docs" + +keywords = ["packaging", "dependency", "poetry"] + +classifiers = [ + "Topic :: Software Development :: Build Tools", + "Topic :: Software Development :: Libraries :: Python Modules" +] + +# Requirements +[tool.poetry.dependencies] +python = "^3.6" +cleo = "^0.6" +cachy = { version = "^0.2.0", extras = ["msgpack"] } + +[tool.poetry.dependencies.pendulum] +version = "^1.4" +markers= 'python_version ~= "2.7" and sys_platform == "win32" or python_version in "3.4 3.5"' +optional = true + +[tool.poetry.dev-dependencies] +pytest = "~3.4" + +[tool.poetry.extras] +time = ["pendulum"] + +[tool.poetry.scripts] +my-script = "my_package:main" +my-2nd-script = "my_package:main2" +extra-script = {callable = "my_package.extra:main", extras = ["time"]} + +[tool.poetry.urls] +"Issue Tracker" = "https://github.com/python-poetry/poetry/issues" diff --git a/tests/masonry/builders/test_wheel.py b/tests/masonry/builders/test_wheel.py index 36f8c27170b..b1a8b636c6b 100644 --- a/tests/masonry/builders/test_wheel.py +++ b/tests/masonry/builders/test_wheel.py @@ -192,3 +192,20 @@ def test_wheel_package_pep_561_stub_only_includes_typed_marker(): with zipfile.ZipFile(str(whl)) as z: assert "pkg-stubs/py.typed" in z.namelist() + + +def test_wheel_includes_licenses_in_correct_paths(): + root = fixtures_dir / "licenses_and_copying" + WheelBuilder.make(Factory().create_poetry(root), NullEnv(), NullIO()) + + whl = root / "dist" / "my_package-1.2.3-py3-none-any.whl" + + assert whl.exists() + with zipfile.ZipFile(str(whl)) as z: + assert "my_package-1.2.3.dist-info/COPYING" in z.namelist() + assert "my_package-1.2.3.dist-info/COPYING.txt" in z.namelist() + assert "my_package-1.2.3.dist-info/LICENSE" in z.namelist() + assert "my_package-1.2.3.dist-info/LICENSE.md" in z.namelist() + assert "my_package-1.2.3.dist-info/LICENSES/CUSTOM-LICENSE" in z.namelist() + assert "my_package-1.2.3.dist-info/LICENSES/BSD-3.md" in z.namelist() + assert "my_package-1.2.3.dist-info/LICENSES/MIT.txt" in z.namelist()