diff --git a/src/poetry/core/masonry/builders/sdist.py b/src/poetry/core/masonry/builders/sdist.py index ae0222cf0..c7e761e37 100644 --- a/src/poetry/core/masonry/builders/sdist.py +++ b/src/poetry/core/masonry/builders/sdist.py @@ -321,7 +321,11 @@ def find_files_to_add(self, exclude_build: bool = False) -> set[BuildIncludeFile to_add = super().find_files_to_add(exclude_build) # add any additional files, starting with all LICENSE files - additional_files: set[Path] = set(self._path.glob("LICENSE*")) + additional_files: set[Path] = set() + include_files_patterns = {"COPYING*", "LICEN[SC]E*", "AUTHORS*", "NOTICE*"} + + for pattern in include_files_patterns: + additional_files.update(self._path.glob(pattern)) # add script files additional_files.update(self.convert_script_files()) diff --git a/src/poetry/core/masonry/builders/wheel.py b/src/poetry/core/masonry/builders/wheel.py index ab8bd5f92..3dbe27588 100644 --- a/src/poetry/core/masonry/builders/wheel.py +++ b/src/poetry/core/masonry/builders/wheel.py @@ -288,21 +288,22 @@ def prepare_metadata(self, metadata_directory: Path) -> Path: with (dist_info / "METADATA").open("w", encoding="utf-8", newline="\n") as f: self._write_metadata_file(f) - license_files = set() - for base in ("COPYING", "LICENSE"): - license_files.add(self._path / base) - license_files.update(self._path.glob(base + ".*")) + legal_files: set[Path] = set() + include_files_globs = {"COPYING*", "LICEN[SC]E*", "AUTHORS*", "NOTICE*"} - license_files.update(self._path.joinpath("LICENSES").glob("**/*")) + for file in include_files_globs: + legal_files.update(self._path.glob(file)) - for license_file in license_files: - if not license_file.is_file(): - logger.debug(f"Skipping: {license_file.as_posix()}") + legal_files.update(self._path.joinpath("LICENSES").glob("**/*")) + + for legal_file in legal_files: + if not legal_file.is_file(): + logger.debug(f"Skipping: {legal_file.as_posix()}") continue - dest = dist_info / license_file.relative_to(self._path) + dest = dist_info / legal_file.relative_to(self._path) dest.parent.mkdir(parents=True, exist_ok=True) - shutil.copy(license_file, dest) + shutil.copy(legal_file, dest) return dist_info diff --git a/tests/masonry/builders/fixtures/complete/AUTHORS b/tests/masonry/builders/fixtures/complete/AUTHORS new file mode 100644 index 000000000..e69de29bb diff --git a/tests/masonry/builders/fixtures/complete/COPYING b/tests/masonry/builders/fixtures/complete/COPYING new file mode 100644 index 000000000..e69de29bb diff --git a/tests/masonry/builders/fixtures/complete/LICENCE b/tests/masonry/builders/fixtures/complete/LICENCE new file mode 100644 index 000000000..e69de29bb diff --git a/tests/masonry/builders/test_complete.py b/tests/masonry/builders/test_complete.py index 44cbfbd72..36a9c8f2e 100644 --- a/tests/masonry/builders/test_complete.py +++ b/tests/masonry/builders/test_complete.py @@ -133,6 +133,9 @@ def test_complete(no_vcs: bool) -> None: "my_package-1.2.3.dist-info/LICENSE", "my_package-1.2.3.dist-info/METADATA", "my_package-1.2.3.dist-info/WHEEL", + "my_package-1.2.3.dist-info/COPYING", + "my_package-1.2.3.dist-info/LICENCE", + "my_package-1.2.3.dist-info/AUTHORS", ], key=lambda x: Path(x), ), diff --git a/tests/masonry/builders/test_sdist.py b/tests/masonry/builders/test_sdist.py index 7a76bc653..8ae9afea1 100644 --- a/tests/masonry/builders/test_sdist.py +++ b/tests/masonry/builders/test_sdist.py @@ -178,6 +178,9 @@ def test_find_files_to_add() -> None: result = {f.relative_to_source_root() for f in builder.find_files_to_add()} assert result == { + Path("AUTHORS"), + Path("COPYING"), + Path("LICENCE"), Path("LICENSE"), Path("README.rst"), Path("bin/script.sh"),