@@ -333,22 +333,28 @@ def _ensure_worker_config(python_exe: str, site_packages: str, multiversion_base
333333
334334def _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