Skip to content

Commit a50de74

Browse files
committed
Update 2 code files
Modified: • src/omnipkg/core.py (+1/-1 lines) • src/omnipkg/isolation/worker_daemon.py (+20/-14 lines) [gitship-generated]
1 parent 8d1f73a commit a50de74

2 files changed

Lines changed: 21 additions & 15 deletions

File tree

src/omnipkg/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16223,7 +16223,7 @@ def _run_pip_install(
1622316223
else:
1622416224
safe_print(f"[UV-PATH] FFI skipped (unavailable) — trying daemon", file=sys.stderr)
1622516225

16226-
# ── PATH 2: daemon run_uv (~IPC overhead) ──────────────
16226+
# ── PATH 2: run_uv (~IPC overhead) ──────────────
1622716227
_t0 = time.perf_counter()
1622816228
try:
1622916229
from omnipkg.isolation.worker_daemon import DaemonClient

src/omnipkg/isolation/worker_daemon.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -333,22 +333,28 @@ def _ensure_worker_config(python_exe: str, site_packages: str, multiversion_base
333333

334334
def _get_venv_temp_dir() -> str:
335335
"""
336-
Return a temp dir scoped to this exact (venv, project) pair.
337-
Uses sys.prefix — always valid for venv/conda/miniforge/subprocess.
338-
Adds project root so the same venv reused across repos stays isolated.
336+
Return a temp dir scoped to the current virtual environment.
337+
This exactly mirrors ConfigManager._get_env_id() so that the daemon
338+
and the core Omnipkg application share the same namespace.
339339
"""
340340
import hashlib
341-
# sys.prefix is the canonical env root — reliable in all contexts
342-
identity = sys.prefix
343-
# Add project root if we can find it (prevents same venv across repos colliding)
344-
try:
345-
project_root = Path(__file__).resolve().parent.parent.parent
346-
if (project_root / "pyproject.toml").exists():
347-
identity = f"{sys.prefix}:{project_root}"
348-
except Exception:
349-
pass
350-
venv_hash = hashlib.sha1(identity.encode()).hexdigest()[:10]
351-
d = os.path.join(OMNIPKG_TEMP_DIR, venv_hash)
341+
import platform
342+
343+
# 1. Respect the override if set (used by ConfigManager)
344+
env_id = os.environ.get("OMNIPKG_ENV_ID_OVERRIDE")
345+
346+
# 2. Replicate _canonical_path_str from ConfigManager
347+
if not env_id:
348+
venv_path = Path(sys.prefix)
349+
if platform.system() == "Windows":
350+
canonical = str(venv_path.resolve()).lower()
351+
else:
352+
canonical = str(venv_path.resolve())
353+
354+
env_id = hashlib.md5(canonical.encode()).hexdigest()[:8]
355+
356+
# Store daemon files cleanly in a shared env directory
357+
d = os.path.join(OMNIPKG_TEMP_DIR, f"env_{env_id}")
352358
os.makedirs(d, exist_ok=True)
353359
return d
354360

0 commit comments

Comments
 (0)