@@ -235,21 +235,6 @@ if [[ ${#EXTRA_GROUPS[@]} -gt 0 && ${#EXCLUDE_GROUPS[@]} -gt 0 ]]; then
235235 done
236236fi
237237
238- # TORCH_GROUP (env var) is the single source of truth for torch pinning; a
239- # --with-<torch_2_*> flag that disagrees with it is almost certainly a
240- # mistake (e.g. TORCH_GROUP left set from a prior `make` invocation) rather
241- # than an intentional double-specification, so fail loudly instead of
242- # leaving it to a raw `uv` conflicting-groups resolver error.
243- if [[ -n " ${TORCH_GROUP:- } " ]]; then
244- for GROUP in " ${EXTRA_GROUPS[@]:- } " ; do
245- if [[ " ${CONFLICTING_GROUPS[*]} " == * " ${GROUP} " * && " $GROUP " != " $TORCH_GROUP " ]]; then
246- echo " Error: --with-$GROUP conflicts with TORCH_GROUP=$TORCH_GROUP ." >&2
247- echo " TORCH_GROUP is the source of truth; unset it or set it to '$GROUP ' instead." >&2
248- exit 1
249- fi
250- done
251- fi
252-
253238# Validate venv name contains only allowed characters
254239if [[ ! " $VENV " =~ ^[a-zA-Z0-9._/-]+$ ]]; then
255240 echo " Error: Virtual environment name contains invalid characters"
@@ -353,13 +338,12 @@ SYNC_CMD=(uv sync --active)
353338if [[ " $ALL_GROUPS " == " true" ]]; then
354339 SYNC_CMD+=(--all-groups)
355340 # Exclude conflicting torch groups other than the one TORCH_GROUP or
356- # --with-<group> selects, so --all-groups doesn't trip the mutual
357- # -conflicts declaration in pyproject.toml.
341+ # --with-<group> selects, so --all-groups doesn't try to sync every
342+ # torch_2_* group at once. If both TORCH_GROUP and --with-<other-group>
343+ # name different groups, neither gets excluded here and `uv sync` itself
344+ # rejects the combination via its own conflicting-groups resolution.
358345 for GROUP in " ${CONFLICTING_GROUPS[@]} " ; do
359- GROUP_REQUESTED=false
360- [[ " $GROUP " == " ${TORCH_GROUP:- } " ]] && GROUP_REQUESTED=true
361- [[ " ${EXTRA_GROUPS[*]:- } " == * " ${GROUP} " * ]] && GROUP_REQUESTED=true
362- if [[ " $GROUP_REQUESTED " == " false" ]]; then
346+ if [[ " $GROUP " != " ${TORCH_GROUP:- } " ]] && [[ ! " ${EXTRA_GROUPS[*]:- } " == * " ${GROUP} " * ]]; then
363347 SYNC_CMD+=(--no-group " $GROUP " )
364348 fi
365349 done
@@ -368,13 +352,12 @@ elif [[ ${#EXTRA_GROUPS[@]} -gt 0 ]]; then
368352 SYNC_CMD+=(--group " $GROUP " )
369353 done
370354fi
371- # TORCH_GROUP is the single source of truth for torch pinning: fold it in
372- # unless --all-groups already swept it up or a --with-<group> above already
373- # requested it explicitly (the earlier guard ensures no disagreement).
374- TORCH_GROUP_ALREADY_SYNCED=false
375- [[ " $ALL_GROUPS " == " true" ]] && TORCH_GROUP_ALREADY_SYNCED=true
376- [[ " ${EXTRA_GROUPS[*]:- } " == * " ${TORCH_GROUP:- } " * ]] && TORCH_GROUP_ALREADY_SYNCED=true
377- if [[ -n " ${TORCH_GROUP:- } " && " $TORCH_GROUP_ALREADY_SYNCED " == " false" ]]; then
355+ # TORCH_GROUP is the single source of truth for torch pinning: append it
356+ # unconditionally (already covered under --all-groups by not being
357+ # excluded above). A disagreeing --with-<other-torch-group> ends up as a
358+ # second, different --group flag here, which `uv sync` itself rejects via
359+ # its conflicting-groups resolution rather than a bespoke check.
360+ if [[ -n " ${TORCH_GROUP:- } " && " $ALL_GROUPS " != " true" ]]; then
378361 SYNC_CMD+=(--group " $TORCH_GROUP " )
379362fi
380363# Apply explicit group exclusions (e.g., --without-coreai)
0 commit comments