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
8 changes: 7 additions & 1 deletion backend/src/hatchling/builders/sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def construct_setup_py_file(self, packages):
return contents

def get_default_build_data(self):
# Check for inclusion first to avoid redundant pattern matching
build_data = {'artifacts': []}
if not self.config.include_path('pyproject.toml'):
build_data['artifacts'].append('/pyproject.toml')
Expand All @@ -242,7 +243,12 @@ def get_default_build_data(self):
if not self.config.include_path(license_file):
build_data['artifacts'].append('/{}'.format(license_file))

build_data['artifacts'].append('/{}'.format(DEFAULT_BUILD_SCRIPT))
if not self.config.include_path(DEFAULT_BUILD_SCRIPT):
build_data['artifacts'].append('/{}'.format(DEFAULT_BUILD_SCRIPT))

if not self.config.include_path('.gitignore'):
build_data['artifacts'].append('/.gitignore')

return build_data

@property
Expand Down
4 changes: 4 additions & 0 deletions docs/meta/history.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ This is the first release candidate for Hatch v1, a complete rewrite.

### Unreleased

***Added:***

- Always include any root `.gitignore` file for source distributions so recursive builds are guaranteed to be identical

***Fixed:***

- Fix metadata handling of non-ASCII characters in README files for source distributions on Python 2
Expand Down
4 changes: 3 additions & 1 deletion tests/backend/builders/test_sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,9 @@ def initialize(self, version, build_data):
'hatch': {
'version': {'path': 'my_app/__about__.py'},
'build': {
'targets': {'sdist': {'versions': ['standard'], 'exclude': [DEFAULT_BUILD_SCRIPT]}},
'targets': {
'sdist': {'versions': ['standard'], 'exclude': [DEFAULT_BUILD_SCRIPT, '.gitignore']}
},
'artifacts': ['my_app/lib.so'],
'hooks': {'custom': {'path': DEFAULT_BUILD_SCRIPT}},
},
Expand Down