Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fc64f28
[WIP] Start implementation of entrypoint support
zooba Nov 20, 2025
8b83213
[WIP] Updated, implemented, and existing tests pass
zooba Nov 24, 2025
7ff8626
Add test
zooba Nov 25, 2025
1263c28
Improved script and fixed names
zooba Nov 25, 2025
fc4793f
Fix tests
zooba Nov 25, 2025
bd20de5
Fix tests
zooba Nov 25, 2025
36118d8
Add tests to improve coverage
zooba Nov 26, 2025
81808f3
More test coverage
zooba Nov 26, 2025
2a3839b
Minor refactor, improved test coverage
zooba Nov 27, 2025
16a60c1
Remove unused import
zooba Nov 27, 2025
52d27a7
Add comment and update scratch key
zooba Nov 27, 2025
e05fbad
Add some missing log messages
zooba Nov 27, 2025
e621dd4
Minor bug fixes
zooba Nov 27, 2025
5916e76
Properly handle launching script executable (not DLL)
zooba Nov 27, 2025
5be8d04
Ensure pip.exe exists
zooba Dec 2, 2025
0a3924e
Merge main
zooba Dec 3, 2025
2069514
Add welcome message
zooba Dec 3, 2025
fddc8cc
Add refresh step to entrypoint test
zooba Dec 3, 2025
c67f0e5
Fix paths
zooba Dec 3, 2025
7f24d36
Minor refactoring on alias creation
zooba Dec 3, 2025
ea6d7c7
Fix calls
zooba Dec 3, 2025
935ab05
Merge main
zooba Dec 8, 2025
198a73f
Refactor and simplify code for aliases
zooba Dec 9, 2025
2eec6d2
Improved edge case handling and test
zooba Dec 9, 2025
a36f76a
Update args
zooba Dec 9, 2025
fb9b7c0
Remove some dead code
zooba Dec 9, 2025
13c57b7
Naming conventions
zooba Dec 9, 2025
42b51bb
Fixes and improvements suggested by reviewer
zooba Dec 9, 2025
753b295
Split names before testing
zooba Dec 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improved edge case handling and test
  • Loading branch information
zooba committed Dec 9, 2025
commit 2eec6d2105752acae7c9376413fe5b56c2137544
57 changes: 43 additions & 14 deletions src/manage/install_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,34 +216,62 @@ def _calc(prefix, filename, calculate_dest=calculate_dest):


def _create_shortcut_pep514(cmd, install, shortcut):
from .pep514utils import update_registry
update_registry(cmd.pep514_root, install, shortcut, cmd.tags)
try:
from .pep514utils import update_registry
root = cmd.pep514_root
except (ImportError, AttributeError):
LOGGER.debug("Skipping PEP 514 creation.", exc_info=True)
return
update_registry(root, install, shortcut, cmd.tags)


def _cleanup_shortcut_pep514(cmd, install_shortcut_pairs):
from .pep514utils import cleanup_registry
cleanup_registry(cmd.pep514_root, {s["Key"] for i, s in install_shortcut_pairs}, cmd.tags)
try:
from .pep514utils import cleanup_registry
root = cmd.pep514_root
except (ImportError, AttributeError):
LOGGER.debug("Skipping PEP 514 cleanup.", exc_info=True)
return
cleanup_registry(root, {s["Key"] for i, s in install_shortcut_pairs}, getattr(cmd, "tags", None))


def _create_start_shortcut(cmd, install, shortcut):
from .startutils import create_one
create_one(cmd.start_folder, install, shortcut, cmd.tags)
try:
from .startutils import create_one
root = cmd.start_folder
except (ImportError, AttributeError):
LOGGER.debug("Skipping Start shortcut creation.", exc_info=True)
return
create_one(root, install, shortcut, cmd.tags)


def _cleanup_start_shortcut(cmd, install_shortcut_pairs):
from .startutils import cleanup
cleanup(cmd.start_folder, [s for i, s in install_shortcut_pairs], cmd.tags)
try:
from .startutils import cleanup
root = cmd.start_folder
except (ImportError, AttributeError):
LOGGER.debug("Skipping Start shortcut cleanup.", exc_info=True)
return
cleanup(root, [s for i, s in install_shortcut_pairs], getattr(cmd, "tags", None))


def _create_arp_entry(cmd, install, shortcut):
# ARP = Add/Remove Programs
from .arputils import create_one
create_one(install, shortcut, cmd.tags)
try:
from .arputils import create_one
except ImportError:
LOGGER.debug("Skipping ARP entry creation.", exc_info=True)
return
create_one(install, shortcut, getattr(cmd, "tags", None))


def _cleanup_arp_entries(cmd, install_shortcut_pairs):
from .arputils import cleanup
cleanup([i for i, s in install_shortcut_pairs], cmd.tags)
try:
from .arputils import cleanup
except ImportError:
LOGGER.debug("Skipping ARP entry cleanup.", exc_info=True)
return
cleanup([i for i, s in install_shortcut_pairs], getattr(cmd, "tags", None))


def _create_entrypoints(cmd, install, shortcut):
Expand Down Expand Up @@ -279,7 +307,7 @@ def update_all_shortcuts(cmd, *, _aliasutils=None):
try:
aliases.extend(_aliasutils.calculate_aliases(cmd, i))
except LookupError:
LOGGER.warn("Failed to process aliases for %s.", i["display-name"])
LOGGER.warn("Failed to process aliases for %s.", i.get("display-name", i["id"]))
LOGGER.debug("TRACEBACK", exc_info=True)
_aliasutils.create_aliases(cmd, aliases)
_aliasutils.cleanup_aliases(cmd, preserve=aliases)
Expand All @@ -301,7 +329,8 @@ def update_all_shortcuts(cmd, *, _aliasutils=None):
shortcut_written.setdefault(s["kind"], []).append((i, s))

for k, (_, cleanup) in SHORTCUT_HANDLERS.items():
cleanup(cmd, shortcut_written.get(k, []))
if cleanup:
cleanup(cmd, shortcut_written.get(k, []))


def print_cli_shortcuts(cmd):
Expand Down
30 changes: 18 additions & 12 deletions tests/test_install_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class Cmd:
def get_installs(self):
return [
{
"id": "test",
"alias": [
{"name": "python3.exe", "target": "p.exe"},
{"name": "pythonw3.exe", "target": "pw.exe", "windowed": 1},
Expand All @@ -189,22 +190,27 @@ def get_installs(self):
(prefix / "p.exe").write_bytes(b"")
(prefix / "pw.exe").write_bytes(b"")

written = []
def create_alias(*a):
written.append(a)

monkeypatch.setattr(IC, "SHORTCUT_HANDLERS", {
"site-dirs": (lambda *a: None,) * 2,
})
created = []

IC.update_all_shortcuts(Cmd(), _create_alias=create_alias)
class AliasUtils:
import manage.aliasutils as AU
calculate_aliases = staticmethod(AU.calculate_aliases)

@staticmethod
def create_aliases(cmd, aliases):
created.extend(aliases)

@staticmethod
def cleanup_aliases(cmd, preserve):
pass

IC.update_all_shortcuts(Cmd(), _aliasutils=AliasUtils)

if default:
# Main test: python.exe and pythonw.exe are added in automatically
assert sorted(w[2]["name"] for w in written) == ["python.exe", "python3.exe", "pythonw.exe", "pythonw3.exe"]
assert sorted(a.name for a in created) == ["python", "python3.exe", "pythonw", "pythonw3.exe"]
else:
assert sorted(w[2]["name"] for w in written) == ["python3.exe", "pythonw3.exe"]
assert sorted(a.name for a in created) == ["python3.exe", "pythonw3.exe"]
# Ensure we still only have the two targets
assert set(w[3].name for w in written) == {"p.exe", "pw.exe"}
# Ensure we got an empty set passed in each time
assert [w[4] for w in written] == [set()] * len(written)
assert set(a.target for a in created) == {"p.exe", "pw.exe"}
Loading