Skip to content

Commit

Permalink
Merge pull request #1634 from daa/pyproject.toml-in-sdist
Browse files Browse the repository at this point in the history
Include pyproject.toml in sdist
  • Loading branch information
jaraco committed Jan 27, 2019
2 parents 97e8ad4 + d53e024 commit 7a4a99a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/1634.change.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Include ``pyproject.toml`` in source distribution by default.
8 changes: 8 additions & 0 deletions setuptools/command/sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ def __read_template_hack(self):
if has_leaky_handle:
read_template = __read_template_hack

def _add_defaults_optional(self):
if six.PY2:
sdist_add_defaults._add_defaults_optional(self)
else:
super()._add_defaults_optional()
if os.path.isfile('pyproject.toml'):
self.filelist.append('pyproject.toml')

def _add_defaults_python(self):
"""getting python files"""
if self.distribution.has_pure_modules():
Expand Down
14 changes: 14 additions & 0 deletions setuptools/tests/test_sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,20 @@ def test_sdist_with_latin1_encoded_filename(self):
except UnicodeDecodeError:
filename not in cmd.filelist.files

def test_pyproject_toml_in_sdist(self):
"""
Check if pyproject.toml is included in source distribution if present
"""
open(os.path.join(self.temp_dir, 'pyproject.toml'), 'w').close()
dist = Distribution(SETUP_ATTRS)
dist.script_name = 'setup.py'
cmd = sdist(dist)
cmd.ensure_finalized()
with quiet():
cmd.run()
manifest = cmd.filelist.files
assert 'pyproject.toml' in manifest


def test_default_revctrl():
"""
Expand Down

0 comments on commit 7a4a99a

Please sign in to comment.