Skip to content

Commit 1fba09b

Browse files
committed
Rework the list of files included in build artifacts
1 parent 1ee19a5 commit 1fba09b

File tree

7 files changed

+26
-15
lines changed

7 files changed

+26
-15
lines changed

src/poetry/core/masonry/builders/sdist.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,11 @@ def find_files_to_add(self, exclude_build: bool = False) -> set[BuildIncludeFile
321321
to_add = super().find_files_to_add(exclude_build)
322322

323323
# add any additional files, starting with all LICENSE files
324-
additional_files: set[Path] = set(self._path.glob("LICENSE*"))
324+
additional_files: set[Path] = set()
325+
include_files_globs = {"COPYING*", "LICEN[SC]E*", "AUTHORS*", "NOTICE*"}
326+
327+
for file in include_files_globs:
328+
additional_files.update(self._path.glob(file))
325329

326330
# add script files
327331
additional_files.update(self.convert_script_files())
@@ -338,12 +342,12 @@ def find_files_to_add(self, exclude_build: bool = False) -> set[BuildIncludeFile
338342
additional_files.update(Path(r) for r in readme)
339343

340344
for additional_file in additional_files:
341-
file = BuildIncludeFile(
345+
include_file = BuildIncludeFile(
342346
path=additional_file, project_root=self._path, source_root=self._path
343347
)
344-
if file.path.exists():
345-
logger.debug(f"Adding: {file.relative_to_source_root()}")
346-
to_add.add(file)
348+
if include_file.path.exists():
349+
logger.debug(f"Adding: {include_file.relative_to_source_root()}")
350+
to_add.add(include_file)
347351

348352
return to_add
349353

src/poetry/core/masonry/builders/wheel.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -288,21 +288,22 @@ def prepare_metadata(self, metadata_directory: Path) -> Path:
288288
with (dist_info / "METADATA").open("w", encoding="utf-8", newline="\n") as f:
289289
self._write_metadata_file(f)
290290

291-
license_files = set()
292-
for base in ("COPYING", "LICENSE"):
293-
license_files.add(self._path / base)
294-
license_files.update(self._path.glob(base + ".*"))
291+
legal_files: set[Path] = set()
292+
include_files_globs = {"COPYING*", "LICEN[SC]E*", "AUTHORS*", "NOTICE*"}
295293

296-
license_files.update(self._path.joinpath("LICENSES").glob("**/*"))
294+
for file in include_files_globs:
295+
legal_files.update(self._path.glob(file))
297296

298-
for license_file in license_files:
299-
if not license_file.is_file():
300-
logger.debug(f"Skipping: {license_file.as_posix()}")
297+
legal_files.update(self._path.joinpath("LICENSES").glob("**/*"))
298+
299+
for legal_file in legal_files:
300+
if not legal_file.is_file():
301+
logger.debug(f"Skipping: {legal_file.as_posix()}")
301302
continue
302303

303-
dest = dist_info / license_file.relative_to(self._path)
304+
dest = dist_info / legal_file.relative_to(self._path)
304305
dest.parent.mkdir(parents=True, exist_ok=True)
305-
shutil.copy(license_file, dest)
306+
shutil.copy(legal_file, dest)
306307

307308
return dist_info
308309

tests/masonry/builders/fixtures/complete/AUTHORS

Whitespace-only changes.

tests/masonry/builders/fixtures/complete/COPYING

Whitespace-only changes.

tests/masonry/builders/fixtures/complete/LICENCE

Whitespace-only changes.

tests/masonry/builders/test_complete.py

+3
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ def test_complete(no_vcs: bool) -> None:
133133
"my_package-1.2.3.dist-info/LICENSE",
134134
"my_package-1.2.3.dist-info/METADATA",
135135
"my_package-1.2.3.dist-info/WHEEL",
136+
"my_package-1.2.3.dist-info/COPYING",
137+
"my_package-1.2.3.dist-info/LICENCE",
138+
"my_package-1.2.3.dist-info/AUTHORS",
136139
],
137140
key=lambda x: Path(x),
138141
),

tests/masonry/builders/test_sdist.py

+3
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ def test_find_files_to_add() -> None:
178178
result = {f.relative_to_source_root() for f in builder.find_files_to_add()}
179179

180180
assert result == {
181+
Path("AUTHORS"),
182+
Path("COPYING"),
183+
Path("LICENCE"),
181184
Path("LICENSE"),
182185
Path("README.rst"),
183186
Path("bin/script.sh"),

0 commit comments

Comments
 (0)