Skip to content

Commit

Permalink
CR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Secrus committed Jan 1, 2024
1 parent c3f5ef0 commit 4c2af8a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
10 changes: 10 additions & 0 deletions src/poetry/core/masonry/builders/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,16 @@ def convert_author(cls, author: str) -> dict[str, str]:

return {"name": name, "email": email}

def _get_legal_files(self) -> set[Path]:
include_files_patterns = {"COPYING*", "LICEN[SC]E*", "AUTHORS*", "NOTICE*"}
files: set[Path] = set()

for pattern in include_files_patterns:
files.update(self._path.glob(pattern))

files.update(self._path.joinpath("LICENSES").glob("**/*"))
return files


class BuildIncludeFile:
def __init__(
Expand Down
7 changes: 3 additions & 4 deletions src/poetry/core/masonry/builders/sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,11 @@ def find_nearest_pkg(rel_path: str) -> tuple[str, str]:
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
# add any additional files
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 legal files
additional_files.update(self._get_legal_files())

# add script files
additional_files.update(self.convert_script_files())
Expand Down
10 changes: 1 addition & 9 deletions src/poetry/core/masonry/builders/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,7 @@ 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)

legal_files: set[Path] = set()
include_files_globs = {"COPYING*", "LICEN[SC]E*", "AUTHORS*", "NOTICE*"}

for file in include_files_globs:
legal_files.update(self._path.glob(file))

legal_files.update(self._path.joinpath("LICENSES").glob("**/*"))

for legal_file in legal_files:
for legal_file in self._get_legal_files():
if not legal_file.is_file():
logger.debug(f"Skipping: {legal_file.as_posix()}")
continue
Expand Down

0 comments on commit 4c2af8a

Please sign in to comment.