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
Fixes and improvements suggested by reviewer
  • Loading branch information
zooba committed Dec 9, 2025
commit 42b51bb4b4fa065ec03d4847e6fa73ecab4bb896
11 changes: 10 additions & 1 deletion src/manage/aliasutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ def replace(self, **kwargs):
@property
def script_code(self):
if self.mod and self.func:
if not self.mod.isidentifier():
LOGGER.warn("Alias %s has an entrypoint with invalid module "
"%r.", self.name, self.mod)
return None
if not self.func.isidentifier():
LOGGER.warn("Alias %s has an entrypoint with invalid function "
"%r.", self.name, self.func)
return None
return SCRIPT_CODE.format(mod=self.mod, func=self.func)


Expand Down Expand Up @@ -183,7 +191,8 @@ def _create_alias(cmd, *, name, target, plat=None, windowed=0, script_code=None,
except OSError:
LOGGER.error("Failed to clean up existing alias. Re-run with -v "
"or check the install log for details.")
LOGGER.info("Failed to remove %s.", p_script, exc_info=True)
LOGGER.info("Failed to remove %s.", p_script)
LOGGER.debug("TRACEBACK", exc_info=True)


def _parse_entrypoint_line(line):
Expand Down
32 changes: 16 additions & 16 deletions src/pymanager/_launch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,35 @@ launch(
STARTUPINFOW si;
PROCESS_INFORMATION pi;
int lastError = 0;
const wchar_t *cmdLine = NULL;
const wchar_t *cmd_line = NULL;

if (orig_cmd_line[0] == L'"') {
cmdLine = wcschr(orig_cmd_line + 1, L'"');
cmd_line = wcschr(orig_cmd_line + 1, L'"');
} else {
cmdLine = wcschr(orig_cmd_line, L' ');
cmd_line = wcschr(orig_cmd_line, L' ');
}

size_t n = wcslen(executable) + wcslen(orig_cmd_line) + wcslen(insert_args) + 6;
wchar_t *newCmdLine = (wchar_t *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, n * sizeof(wchar_t));
if (!newCmdLine) {
size_t n = wcslen(executable) + wcslen(orig_cmd_line) + (insert_args ? wcslen(insert_args) : 0) + 6;
wchar_t *new_cmd_line = (wchar_t *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, n * sizeof(wchar_t));
if (!new_cmd_line) {
lastError = GetLastError();
goto exit;
}

// Skip any requested args, deliberately leaving any trailing spaces
// (we'll skip one later one and add our own space, and preserve multiple)
while (skip_argc-- > 0) {
// (we'll skip one later on and add our own space, and preserve multiple)
while (cmd_line && *cmd_line && skip_argc-- > 0) {
wchar_t c;
while (*++cmdLine && *cmdLine == L' ') { }
while (*++cmdLine && *cmdLine != L' ') { }
while (*++cmd_line && *cmd_line == L' ') { }
while (*++cmd_line && *cmd_line != L' ') { }
}

swprintf_s(newCmdLine, n, L"\"%s\"%s%s%s%s",
swprintf_s(new_cmd_line, n, L"\"%s\"%s%s%s%s",
executable,
(insert_args && *insert_args) ? L" ": L"",
(insert_args && *insert_args) ? insert_args : L"",
(cmdLine && *cmdLine) ? L" " : L"",
(cmdLine && *cmdLine) ? cmdLine + 1 : L"");
(cmd_line && *cmd_line) ? L" " : L"",
(cmd_line && *cmd_line) ? cmd_line + 1 : L"");

#if defined(_WINDOWS)
/*
Expand Down Expand Up @@ -122,7 +122,7 @@ launch(
}

si.dwFlags |= STARTF_USESTDHANDLES;
if (!CreateProcessW(executable, newCmdLine, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)) {
if (!CreateProcessW(executable, new_cmd_line, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)) {
lastError = GetLastError();
goto exit;
}
Expand All @@ -134,8 +134,8 @@ launch(
lastError = GetLastError();
}
exit:
if (newCmdLine) {
HeapFree(GetProcessHeap(), 0, newCmdLine);
if (new_cmd_line) {
HeapFree(GetProcessHeap(), 0, new_cmd_line);
}
return lastError ? HRESULT_FROM_WIN32(lastError) : 0;
}
4 changes: 2 additions & 2 deletions src/pymanager/launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ get_script(wchar_t **result_path)
}
}

wcscpy_s(&path[len], path_len, SUFFIX);
wcscpy_s(&path[len], path_len - len, SUFFIX);

// Check that we have a script file. FindFirstFile should be fastest.
WIN32_FIND_DATAW fd;
Expand Down Expand Up @@ -267,7 +267,7 @@ wmain(int argc, wchar_t **argv)
{
int exit_code;
wchar_t executable[MAXLEN];
wchar_t *script;
wchar_t *script = NULL;

int err = get_executable(executable, MAXLEN);
if (err) {
Expand Down
7 changes: 0 additions & 7 deletions tests/test_alias.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import json
import os
import pytest
import secrets
from pathlib import Path, PurePath

from manage import aliasutils as AU
from manage.exceptions import NoLauncherTemplateError
Expand Down Expand Up @@ -298,10 +295,6 @@ def test_cleanup_aliases(fake_config, tmp_path):
target = tmp_path / "target.exe"
target.write_bytes(b"")

created = []
def _on_create(cmd, **kwargs):
created.append(kwargs)

aliases = [
AU.AliasInfo(install=dict(prefix=tmp_path), name="A", target=target),
AU.AliasInfo(install=dict(prefix=tmp_path), name="B.exe", target=target),
Expand Down
Loading