Skip to content

Prefer default install for shared aliases - #415

Merged
zooba merged 1 commit into
python:mainfrom
Punisheroot:fix/js/default-alias-precedence
Sep 10, 2026
Merged

Prefer default install for shared aliases#415
zooba merged 1 commit into
python:mainfrom
Punisheroot:fix/js/default-alias-precedence

Conversation

@Punisheroot

Copy link
Copy Markdown
Contributor

Summary

  • update_all_shortcuts() now moves the flagged default install to the front before generating global aliases, so shared entrypoints (e.g. pip) resolve to the same runtime as python/pythonw.

Context

BaseCommand.get_installs() keeps precedence order and only sets the default flag for an overridden default (e.g. via PYTHON_MANAGER_DEFAULT). Since create_aliases() is first-match-wins, entrypoint aliases such as pip.exe were claimed by the first install in precedence order, while python/pythonw (yielded only for the default) pointed elsewhere.

Closes #413

Changes

  • src/manage/install_command.py: in update_all_shortcuts(), find the default install and move it front (early-break loop, O(1) when already first). Kept local to this function so py list ordering is unchanged, per maintainer direction.
  • tests/test_install_command.py: added test_update_all_shortcuts_default_first covering a duplicated alias shared between a first non-default and a second default install.

Validation

Compatibility and risk

  • No change to get_installs() ordering, py list, shebang lookup, or python/pythonw handling.
  • Only affects the processing order inside update_all_shortcuts(); per-install Start/PEP 514 shortcuts are order-insensitive.

get_installs() keeps precedence order and only flags an overridden default (e.g. via PYTHON_MANAGER_DEFAULT), so update_all_shortcuts() generated entrypoint aliases such as pip from the first install while python/pythonw came from the default. Move the default install front before alias creation so first-match-wins picks it. Ordering is kept local to preserve py list output.
@Punisheroot
Punisheroot marked this pull request as ready for review September 10, 2026 17:23
@zooba
zooba merged commit d14e65d into python:main Sep 10, 2026
6 checks passed
@zooba

zooba commented Sep 10, 2026

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The pip and py/python aliases refer to different installations whenever PYTHON_MANAGER_DEFAULT is anything but the most recent full release available.

2 participants