diff --git a/backend/src/hatchling/builders/wheel.py b/backend/src/hatchling/builders/wheel.py index 88ccb8054..ad68194b3 100644 --- a/backend/src/hatchling/builders/wheel.py +++ b/backend/src/hatchling/builders/wheel.py @@ -203,8 +203,10 @@ def set_default_file_selection(self) -> None: self.__packages.append(namespace) break else: - self.__include.append('*.py') - self.__exclude.append('test*') + message = ( + 'At least one file selection option must be defined, see: https://hatch.pypa.io/latest/config/build/' + ) + raise ValueError(message) def default_include(self) -> list[str]: if not self.__include_defined: diff --git a/docs/history/hatchling.md b/docs/history/hatchling.md index ee0d35381..7ddafbab0 100644 --- a/docs/history/hatchling.md +++ b/docs/history/hatchling.md @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ***Changed:*** - An error will now be raised if a force-included path does not exist +- An error will now be raised for the `wheel` target if no file selection options are defined ***Added:*** diff --git a/docs/plugins/builder/wheel.md b/docs/plugins/builder/wheel.md index 83f822999..027566cb1 100644 --- a/docs/plugins/builder/wheel.md +++ b/docs/plugins/builder/wheel.md @@ -27,7 +27,7 @@ The builder plugin name is `wheel`. | Version | Description | | --- | --- | | `standard` (default) | The latest standardized format | -| `editable` | A wheel that only ships `.pth` files or import hooks for real-time development | +| `editable` | A wheel that only ships `.pth` files or import hooks for real-time development | ## Default file selection @@ -37,7 +37,8 @@ When the user has not set any [file selection](../../config/build.md#file-select 2. `src//__init__.py` 3. `.py` 4. `//__init__.py` -5. Otherwise, every Python package and file that does not start with the word `test` will be included + +If none of these heuristics are satisfied, an error will be raised. ## Reproducibility diff --git a/tests/backend/builders/test_wheel.py b/tests/backend/builders/test_wheel.py index 4fd7014d3..7fce25a4e 100644 --- a/tests/backend/builders/test_wheel.py +++ b/tests/backend/builders/test_wheel.py @@ -111,15 +111,20 @@ def test_default(self, temp_dir): config = {'project': {'name': 'my-app', 'version': '0.0.1'}} builder = WheelBuilder(str(temp_dir), config=config) - for i in range(2): - namespace_root = temp_dir / f'ns{i}' / 'my_app' / '__init__.py' - namespace_root.ensure_parent_dir_exists() - namespace_root.touch() - - assert builder.config.default_include() == ['*.py'] - assert builder.config.default_exclude() == ['test*'] - assert builder.config.default_packages() == [] - assert builder.config.default_only_include() == [] + for method in ( + builder.config.default_include, + builder.config.default_exclude, + builder.config.default_packages, + builder.config.default_only_include, + ): + with pytest.raises( + ValueError, + match=( + 'At least one file selection option must be defined, see: ' + 'https://hatch.pypa.io/latest/config/build/' + ), + ): + _ = method() def test_unnormalized_name_with_unnormalized_directory(self, temp_dir): config = {'project': {'name': 'MyApp', 'version': '0.0.1'}}