Skip to content

Commit 8c18dc5

Browse files
committed
convert name
1 parent 8edd55c commit 8c18dc5

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

unidep/_pixi.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,15 @@ def _process_dependencies( # noqa: PLR0912
161161
# Also create one environment per feature.
162162
for feat in all_features:
163163
# Environment names cannot use _, only lowercase letters, digits, and -
164-
name = feat.replace("_", "-")
164+
name = feature_name_to_env_name(feat)
165165
pixi_data["environments"][name] = [feat]
166166

167167

168+
def feature_name_to_env_name(feature_name: str) -> str:
169+
"""Convert a feature name to a valid environment name."""
170+
return feature_name.replace("_", "-")
171+
172+
168173
def _write_pixi_toml(
169174
pixi_data: dict[str, dict[str, Any]],
170175
output_file: str | Path | None,

unidep/_pixi_lock.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from ruamel.yaml import YAML
99

1010
from unidep._dependencies_parsing import find_requirements_files
11+
from unidep._pixi import feature_name_to_env_name
1112
from unidep.utils import add_comment_to_file, change_directory
1213

1314
if TYPE_CHECKING:
@@ -180,7 +181,8 @@ def _generate_sub_lock_file(
180181
"""
181182
# Look up the environment for the given feature.
182183
envs = global_lock_data.get("environments", {})
183-
env_data = envs.get(feature_name)
184+
env_name = feature_name_to_env_name(feature_name)
185+
env_data = envs.get(env_name)
184186
if env_data is None:
185187
msg = f"Feature '{feature_name}' not found in the global lock file."
186188
raise ValueError(msg)

0 commit comments

Comments
 (0)