Skip to content

Commit

Permalink
Refactor access to the generate-setup-file configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
sdispater committed Jul 22, 2020
1 parent 6ac8de5 commit b238226
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion poetry/core/masonry/builders/sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def build(self, target_dir=None): # type: (Path) -> Path
else:
tar.addfile(tar_info) # Symlinks & ?

if self._poetry.package.build_config.get("generate-setup-file", True):
if self._poetry.package.build_should_generate_setup():
setup = self.build_setup()
tar_info = tarfile.TarInfo(pjoin(tar_dir, "setup.py"))
tar_info.size = len(setup)
Expand Down
5 changes: 3 additions & 2 deletions poetry/core/masonry/builders/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from io import StringIO

from packaging.tags import sys_tags

from poetry.core import __version__
from poetry.core.semver import parse_constraint
from poetry.core.utils._compat import decode
Expand Down Expand Up @@ -77,7 +78,7 @@ def build(self):
with zipfile.ZipFile(
os.fdopen(fd, "w+b"), mode="w", compression=zipfile.ZIP_DEFLATED
) as zip_file:
if not self._poetry.package.build_config.get("generate-setup-file", True):
if not self._poetry.package.build_should_generate_setup():
self._build(zip_file)
self._copy_module(zip_file)
else:
Expand All @@ -96,7 +97,7 @@ def build(self):

def _build(self, wheel):
if self._package.build_script:
if not self._poetry.package.build_config.get("generate-setup-file", True):
if not self._poetry.package.build_should_generate_setup():
# Since we have a build script but no setup.py generation is required,
# we assume that the build script will build and copy the files
# directly.
Expand Down
3 changes: 3 additions & 0 deletions poetry/core/packages/project_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ def urls(self):
urls.update(self.custom_urls)

return urls

def build_should_generate_setup(self): # type: () -> bool
return self.build_config.get("generate-setup-file", True)

0 comments on commit b238226

Please sign in to comment.