Skip to content

Commit bd6233c

Browse files
committed
Update 1 code files
Modified: • src/omnipkg/dispatcher.py (+25/-8 lines) [gitship-generated]
1 parent bec99fa commit bd6233c

1 file changed

Lines changed: 25 additions & 8 deletions

File tree

src/omnipkg/dispatcher.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -551,10 +551,20 @@ def _maybe_install_c_dispatcher():
551551
# Native bin is up to date. On Windows, hand off to the C dispatcher
552552
# if it exists — it is never locked since 8pkg.exe is what ran us.
553553
if sys.platform == "win32":
554-
_win_try_handoff_to_c_dispatcher(bin_dir, debug)
555-
# If we reach here, _omnipkg_dispatch.exe doesn't exist yet or
556-
# failed the sanity check — fall through to compile below.
557-
# Do NOT return; let the compile path run.
554+
# Only hand off if we were invoked as the 8pkg/omnipkg entrypoint,
555+
# not if we're already a subprocess of the C dispatcher or pip.
556+
# Check: argv[0] must be the .exe entrypoint, not python -m ...
557+
_argv0 = Path(sys.argv[0]).name.lower().replace(".exe", "")
558+
_is_entrypoint = _argv0 in ("8pkg", "omnipkg", "8pkg_", "omnipkg_")
559+
_is_detached = os.environ.get("OMNIPKG_WIN_DETACHED_COMPILE") == "1"
560+
if _is_entrypoint and not _is_detached:
561+
_win_try_handoff_to_c_dispatcher(bin_dir, debug)
562+
# If we reach here: not the entrypoint, or dispatch_exe missing/bad.
563+
# Fall through to compile below (or just return if not entrypoint).
564+
if not _is_entrypoint:
565+
if debug:
566+
print(f"[C-INSTALL] Windows: not entrypoint (argv[0]={sys.argv[0]}) — skip handoff", file=sys.stderr)
567+
return
558568
else:
559569
# Non-Windows: push to adopted dirs then return normally.
560570
for adopted_bin in _collect_all_dispatcher_bin_dirs()[1:]:
@@ -579,12 +589,19 @@ def _maybe_install_c_dispatcher():
579589
# First run after pip install: we are locked. Spawn detached compiler
580590
# which will write _omnipkg_dispatch.exe after we exit, then return
581591
# so the user's command still runs normally via Python this one time.
582-
# Guard: if WE are the detached compiler, don't spawn again — compile.
583-
if os.environ.get("OMNIPKG_WIN_DETACHED_COMPILE") == "1":
584-
pass # fall through to compile below
585-
else:
592+
_argv0 = Path(sys.argv[0]).name.lower().replace(".exe", "")
593+
_is_entrypoint = _argv0 in ("8pkg", "omnipkg", "8pkg_", "omnipkg_")
594+
_is_detached = os.environ.get("OMNIPKG_WIN_DETACHED_COMPILE") == "1"
595+
if _is_detached:
596+
pass # we ARE the detached compiler — fall through to compile
597+
elif _is_entrypoint:
586598
_win_spawn_detached_compiler(debug)
587599
return
600+
else:
601+
# Called from pip build or python -m — don't spawn, just return
602+
if debug:
603+
print(f"[C-INSTALL] Windows: not entrypoint, skip first-run spawn", file=sys.stderr)
604+
return
588605
# _omnipkg_dispatch.exe exists but hash was stale — we can overwrite it
589606
# freely since it is never the running process.
590607
binary_tmp = dispatch_exe.with_name("_omnipkg_dispatch_tmp.exe")

0 commit comments

Comments
 (0)