Skip to content

Commit 9c753a5

Browse files
viccie30ofek
andauthored
Honor env.features when skip-install is set (#826)
* Honor env.features when skip-install is set Fixes: #729 * add release note --------- Co-authored-by: Ofek Lev <[email protected]>
1 parent 4f4f5b2 commit 9c753a5

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

docs/history/hatch.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2424
- Add `dependency_hash` method to the `environment` interface
2525
- The state of installed dependencies for environments is saved as metadata so if dependency definitions have not changed then no checking is performed, which can be computationally expensive
2626
- The `build` command now supports backends other than Hatchling
27+
- Allow the use of `features` for environments when `skip-install` is enabled
2728
- The default is now `__TOKEN__` when prompting for a username for the `publish` command
2829
- Bump the minimum supported version of Hatchling to 1.17.1
2930
- Bump the minimum supported version of `click` to 8.0.6

src/hatch/env/plugin/interface.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,13 @@ def dependencies_complex(self):
310310

311311
# Ensure these are checked last to speed up initial environment creation since
312312
# they will already be installed along with the project
313-
if not self.skip_install and self.dev_mode:
313+
if (not self.skip_install and self.dev_mode) or self.features:
314314
from hatch.utils.dep import get_project_dependencies_complex
315315

316316
dependencies_complex, optional_dependencies_complex = get_project_dependencies_complex(self)
317317

318-
all_dependencies_complex.extend(dependencies_complex.values())
318+
if not self.skip_install and self.dev_mode:
319+
all_dependencies_complex.extend(dependencies_complex.values())
319320

320321
for feature in self.features:
321322
if feature not in optional_dependencies_complex:
@@ -336,7 +337,8 @@ def dependencies(self) -> list[str]:
336337
"""
337338
The list of all [project dependencies](../../config/metadata.md#dependencies) (if
338339
[installed](../../config/environment/overview.md#skip-install) and in
339-
[dev mode](../../config/environment/overview.md#dev-mode)) and
340+
[dev mode](../../config/environment/overview.md#dev-mode)), selected
341+
[optional dependencies](../../config/environment/overview.md#features), and
340342
[environment dependencies](../../config/environment/overview.md#dependencies).
341343
"""
342344
if self._dependencies is None:

tests/env/plugin/test_interface.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,42 @@ def test_full_skip_install(self, isolation, isolated_data_dir, platform):
958958

959959
assert environment.dependencies == ['dep2', 'dep3']
960960

961+
def test_full_skip_install_and_features(self, isolation, isolated_data_dir, platform):
962+
config = {
963+
'project': {
964+
'name': 'my_app',
965+
'version': '0.0.1',
966+
'dependencies': ['dep1'],
967+
'optional-dependencies': {'feat': ['dep4']},
968+
},
969+
'tool': {
970+
'hatch': {
971+
'envs': {
972+
'default': {
973+
'dependencies': ['dep2'],
974+
'extra-dependencies': ['dep3'],
975+
'skip-install': True,
976+
'features': ['feat'],
977+
}
978+
}
979+
}
980+
},
981+
}
982+
project = Project(isolation, config=config)
983+
environment = MockEnvironment(
984+
isolation,
985+
project.metadata,
986+
'default',
987+
project.config.envs['default'],
988+
{},
989+
isolated_data_dir,
990+
isolated_data_dir,
991+
platform,
992+
0,
993+
)
994+
995+
assert environment.dependencies == ['dep2', 'dep3', 'dep4']
996+
961997
def test_full_dev_mode(self, isolation, isolated_data_dir, platform):
962998
config = {
963999
'project': {'name': 'my_app', 'version': '0.0.1', 'dependencies': ['dep1']},

0 commit comments

Comments
 (0)