Skip to content

Commit 9cb496e

Browse files
committed
revert: restore working tree to stable state at 51c6f86
1 parent a7f8174 commit 9cb496e

5 files changed

Lines changed: 182 additions & 198 deletions

File tree

.github/workflows/windows-concurrency-test.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ jobs:
4949
python -m pip install --upgrade pip
5050
pip install -e .
5151
52+
- name: Configure omnipkg for non-interactive use
53+
shell: pwsh
54+
run: |
55+
$configDir = "$HOME\.config\omnipkg"
56+
New-Item -ItemType Directory -Force -Path $configDir | Out-Null
57+
@{ interactive = $false; auto_confirm = $true } | ConvertTo-Json | Out-File -FilePath "$configDir\config.json" -Encoding utf8
58+
Write-Host "✅ Omnipkg configured"
59+
5260
- name: Run Demo (Option 8 - Quantum Multiverse)
5361
shell: cmd
5462
run: omnipkg demo 8 --non-interactive

src/omnipkg/dispatcher.c

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -978,22 +978,14 @@ static void fallback_to_python_v(const char *self_dir, char **argv,
978978

979979
/* Try the config first */
980980
if (!read_self_config(self_dir, py, sizeof(py)) || !file_exists(py)) {
981-
/* Try common names in self_dir, then parent (Scripts/ -> prefix/ on Windows). */
981+
/* Try common names in self_dir */
982982
const char *names[] = {"python3.11","python3.10","python3.9",
983-
"python3","python","python.exe",NULL};
983+
"python3","python",NULL};
984984
int found = 0;
985985
for (int i = 0; names[i]; i++) {
986986
snprintf(py, sizeof(py), "%s/%s", self_dir, names[i]);
987987
if (file_exists(py)) { found = 1; break; }
988988
}
989-
if (!found) {
990-
char parent_dir[MAX_PATH];
991-
dir_of(self_dir, parent_dir, sizeof(parent_dir));
992-
for (int i = 0; names[i]; i++) {
993-
snprintf(py, sizeof(py), "%s/%s", parent_dir, names[i]);
994-
if (file_exists(py)) { found = 1; break; }
995-
}
996-
}
997989
if (!found) {
998990
fprintf(stderr, "omnipkg: cannot find host Python for fallback\n");
999991
exit(1);
@@ -1599,25 +1591,8 @@ int main(int argc, char **argv) {
15991591
if (cli_version) {
16001592
char venv_root[MAX_PATH];
16011593
find_venv_root(self_real, venv_root, sizeof(venv_root));
1602-
1603-
/* Multi-candidate registry lookup: find_venv_root may miss on Windows
1604-
* (uses strrchr('/') only). Try venv_root, self_dir, self_dir parent. */
1605-
int reg_hit = 0;
1606-
if (venv_root[0])
1607-
reg_hit = registry_lookup(venv_root, cli_version,
1608-
target_python, sizeof(target_python));
1609-
if (!reg_hit)
1610-
reg_hit = registry_lookup(self_dir, cli_version,
1611-
target_python, sizeof(target_python));
1612-
if (!reg_hit) {
1613-
char parent_dir[MAX_PATH];
1614-
dir_of(self_dir, parent_dir, sizeof(parent_dir));
1615-
if (parent_dir[0])
1616-
reg_hit = registry_lookup(parent_dir, cli_version,
1617-
target_python, sizeof(target_python));
1618-
}
1619-
1620-
if (reg_hit) {
1594+
if (venv_root[0] && registry_lookup(venv_root, cli_version,
1595+
target_python, sizeof(target_python))) {
16211596
if (!file_exists(target_python)) {
16221597
/* Not adopted yet → fallback to Python for auto-adopt */
16231598
if (debug) fprintf(stderr, "[C-DISPATCH] %s not found → auto-adopt fallback\n", target_python);
@@ -1627,30 +1602,28 @@ int main(int argc, char **argv) {
16271602
fprintf(stderr, "[C-DISPATCH] registry hit %s → %s\n",
16281603
cli_version, target_python);
16291604
} else {
1630-
/* Registry miss — check if self-aware config python matches.
1631-
* Handle Windows where basename may be "python.exe". */
1605+
/* Registry miss — could be the native interpreter (not adopted, so not
1606+
* in registry.json). Check if the self-aware config python matches the
1607+
* requested version before giving up and paying the Python fallback cost. */
16321608
char self_py[MAX_PATH] = "";
16331609
read_self_config(self_dir, self_py, sizeof(self_py));
16341610
if (self_py[0] && file_exists(self_py)) {
1635-
/* Extract version from path. Try both / and \\ separators. */
1611+
/* Extract version from the path, e.g. ".../bin/python3.11" → "3.11" */
16361612
const char *base = strrchr(self_py, '/');
1637-
const char *base2 = strrchr(self_py, '\\');
1638-
if (base2 && (!base || base2 > base)) base = base2;
16391613
base = base ? base + 1 : self_py;
1614+
/* skip "python" prefix */
16401615
const char *ver_in_path = base;
16411616
if (strncmp(ver_in_path, "python", 6) == 0) ver_in_path += 6;
1642-
char ver_buf[32] = "";
1643-
strncpy(ver_buf, ver_in_path, sizeof(ver_buf) - 1);
1644-
char *dot_exe = strstr(ver_buf, ".exe");
1645-
if (dot_exe) *dot_exe = '\0';
1646-
if (strncmp(ver_buf, "3.", 2) == 0 &&
1647-
strcmp(ver_buf, cli_version) == 0) {
1617+
if (strncmp(ver_in_path, "3.", 2) == 0 &&
1618+
strcmp(ver_in_path, cli_version) == 0) {
1619+
/* Native interpreter matches — use it directly, no fallback needed */
16481620
strncpy(target_python, self_py, sizeof(target_python) - 1);
16491621
target_python[sizeof(target_python) - 1] = '\0';
16501622
if (debug)
16511623
fprintf(stderr, "[C-DISPATCH] native match %s → %s\n",
16521624
cli_version, target_python);
16531625
} else {
1626+
/* Genuinely unknown version → Python fallback for auto-adopt */
16541627
if (debug) fprintf(stderr, "[C-DISPATCH] unknown version %s → fallback\n", cli_version);
16551628
fallback_to_python_v(self_dir, argv, cli_version);
16561629
}

src/tests/test_concurrent_install.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,30 @@ def ensure_daemon_running(interpreter_paths: list) -> bool:
192192
stdout=subprocess.DEVNULL,
193193
stderr=subprocess.DEVNULL,
194194
)
195-
# Poll until daemon answers or we time out.
196-
# Do NOT bail on launcher rc — on Windows the launcher exits with
197-
# rc=1 even when the daemon it spawned is still starting (detached).
198-
# The only reliable signal is the socket answering.
195+
# Poll until daemon answers, launcher exits with error, or we time out.
199196
_came_up = False
200197
for i in range(60):
201198
time.sleep(0.5)
202199
rc = proc.poll()
203-
if rc is not None:
204-
safe_print(f" ℹ️ Launcher exited rc={rc} — polling socket for daemon")
200+
if rc is not None and rc != 0:
201+
# Launcher exited non-zero — bail immediately, don't burn
202+
# the remaining 30s pretending the daemon might appear.
203+
try:
204+
_out = proc.stdout.read().decode("utf-8", errors="replace").strip()
205+
_err = proc.stderr.read().decode("utf-8", errors="replace").strip()
206+
except Exception:
207+
_out = _err = ""
208+
safe_print(f" ❌ Launcher exited rc={rc} — daemon start failed")
209+
if _out:
210+
for ln in _out.splitlines():
211+
safe_print(f" [launcher stdout] {ln}")
212+
if _err:
213+
for ln in _err.splitlines():
214+
safe_print(f" [launcher stderr] {ln}")
215+
dump_daemon_log("DAEMON LOG ON FAILURE", only_on_error=False)
216+
return False
217+
if rc == 0 and i == 0:
218+
safe_print(" ℹ️ Launcher exited rc=0 — daemon detached")
205219
status = client.status()
206220
if status.get("success"):
207221
_daemon_elapsed = (time.perf_counter() - _daemon_start) * 1000

0 commit comments

Comments
 (0)