Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions poetry/core/masonry/builders/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,11 @@ def find_files_to_add(
logger.debug(" - Adding: {}".format(str(file)))
to_add.add(include_file)

# If a build script is specified and explicitly required
# we add it to the list of files
# add build script if it is specified and explicitly required
if self._package.build_script and not exclude_build:
to_add.add(
BuildIncludeFile(
path=self._path / self._package.build_script,
source_root=self._path,
path=self._package.build_script, source_root=self._path
)
)

Expand Down
40 changes: 18 additions & 22 deletions poetry/core/masonry/builders/sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from posixpath import join as pjoin
from pprint import pformat
from typing import Iterator
from typing import List
from typing import Set

from poetry.core.utils._compat import Path
from poetry.core.utils._compat import decode
Expand Down Expand Up @@ -76,7 +76,7 @@ def build(self, target_dir=None): # type: (Path) -> Path

files_to_add = self.find_files_to_add(exclude_build=False)

for file in files_to_add:
for file in sorted(files_to_add, key=lambda x: x.relative_to_source_root()):
tar_info = tar.gettarinfo(
str(file.path),
arcname=pjoin(tar_dir, str(file.relative_to_source_root())),
Expand Down Expand Up @@ -305,32 +305,28 @@ def find_nearest_pkg(rel_path):

def find_files_to_add(
self, exclude_build=False
): # type: (bool) -> List[BuildIncludeFile]
): # type: (bool) -> Set[BuildIncludeFile]
to_add = super(SdistBuilder, self).find_files_to_add(exclude_build)

# Include project files
logger.debug(" - Adding: pyproject.toml")
to_add.add(
BuildIncludeFile(path=self._path / "pyproject.toml", source_root=self._path)
)
# add any additional files, starting with all LICENSE files
additional_files = {
license_file for license_file in self._path.glob("LICENSE*")
}

# If a license file exists, add it
for license_file in self._path.glob("LICENSE*"):
license_file = BuildIncludeFile(path=license_file, source_root=self._path)
logger.debug(" - Adding: {}".format(license_file.relative_to_source_root()))
to_add.add(license_file)
# Include project files
additional_files.add("pyproject.toml")

# If a README is specified we need to include it to avoid errors
# add readme if it is specified
if "readme" in self._poetry.local_config:
readme = BuildIncludeFile(
path=self._path / self._poetry.local_config["readme"],
source_root=self._path,
)
if readme.path.exists():
logger.debug(" - Adding: {}".format(readme.relative_to_source_root()))
to_add.add(readme)
additional_files.add(self._poetry.local_config["readme"])

for file in additional_files:
file = BuildIncludeFile(path=file, source_root=self._path)
if file.path.exists():
logger.debug(" - Adding: {}".format(file.relative_to_source_root()))
to_add.add(file)

return sorted(list(to_add), key=lambda x: x.relative_to_source_root())
return to_add

@classmethod
def convert_dependencies(cls, package, dependencies):
Expand Down