1919from omnipkg .core import ConfigManager , omnipkg as OmnipkgCore
2020from omnipkg .i18n import _
2121
22- # Configuration
23- DEFAULT_RICH_VERSION = "13.7.1"
22+ # Configuration - detected at runtime from main env
23+ DEFAULT_RICH_VERSION = None
2424BUBBLE_VERSIONS_TO_TEST = ["13.5.3" , "13.4.2" ]
2525
2626def print_header (title ):
@@ -36,15 +36,13 @@ def ensure_daemon_running():
3636
3737 if not status .get ("success" ):
3838 safe_print (" 🚀 Daemon not running. Starting it now..." )
39- # Start daemon in background
4039 subprocess .Popen (
4140 [sys .executable , "-m" , "omnipkg.isolation.worker_daemon" , "start" ],
4241 stdout = subprocess .DEVNULL ,
4342 stderr = subprocess .DEVNULL ,
44- creationflags = 0x00000008 if sys .platform == 'win32' else 0 , # DETACHED
43+ creationflags = 0x00000008 if sys .platform == 'win32' else 0 ,
4544 )
46-
47- # Wait for readiness
45+
4846 safe_print (" ⏳ Waiting for daemon..." , end = "" , flush = True )
4947 for i in range (50 ):
5048 time .sleep (0.2 )
@@ -53,7 +51,7 @@ def ensure_daemon_running():
5351 safe_print (" ✅ Ready." )
5452 return client
5553 if i % 5 == 0 : safe_print ("." , end = "" , flush = True )
56-
54+
5755 raise RuntimeError ("Daemon failed to start" )
5856 else :
5957 safe_print (" ✅ Daemon is already running." )
@@ -62,21 +60,18 @@ def ensure_daemon_running():
6260
6361def fast_setup (omnipkg_core : OmnipkgCore ):
6462 """
65- Checks for existing installations. Installs ONLY if missing .
63+ Detects the actual main env rich version, then ensures bubbles exist .
6664 """
65+ global DEFAULT_RICH_VERSION
66+
6767 print_header ("STEP 1: Fast Environment Check" )
6868
69- # 1. Check Main Environment
69+ # 1. Read whatever rich version is actually in main env — don't fight it
7070 try :
71- current_main = version ("rich" )
72- if current_main == DEFAULT_RICH_VERSION :
73- safe_print (f" ✅ Main Env: rich=={ DEFAULT_RICH_VERSION } is already installed." )
74- else :
75- safe_print (f" ⚠️ Main Env: Found v{ current_main } , switching to v{ DEFAULT_RICH_VERSION } ..." )
76- omnipkg_core .smart_install ([f"rich=={ DEFAULT_RICH_VERSION } " ])
71+ DEFAULT_RICH_VERSION = version ("rich" )
72+ safe_print (f" ✅ Main Env: rich=={ DEFAULT_RICH_VERSION } (using as-is)" )
7773 except PackageNotFoundError :
78- safe_print (f" ❌ Main Env: rich missing. Installing v{ DEFAULT_RICH_VERSION } ..." )
79- omnipkg_core .smart_install ([f"rich=={ DEFAULT_RICH_VERSION } " ])
74+ raise RuntimeError ("rich is not installed in the main environment at all — cannot run test" )
8075
8176 # 2. Check Bubbles
8277 for v in BUBBLE_VERSIONS_TO_TEST :
@@ -92,37 +87,33 @@ def test_version_via_daemon(target_version: str, client: DaemonClient, is_bubble
9287 Verifies version using the Daemon.
9388 """
9489 spec = f"rich=={ target_version } "
95-
90+
9691 if is_bubble :
9792 safe_print (_ (' ⚡ Verifying v{} via Daemon Worker...' ).format (target_version ))
9893 proxy = DaemonProxy (client , spec )
9994 else :
100- # For main env testing via daemon, we just use 'rich' without version constraints
101- # or we rely on the daemon's default environment if no spec provided (but here we be explicit)
10295 safe_print (_ (' 🏠 Verifying v{} via Daemon (Main Env check)...' ).format (target_version ))
10396 proxy = DaemonProxy (client , spec )
10497
10598 code = "from importlib.metadata import version; import rich; print(f'VERSION={version(\" rich\" )}|PATH={rich.__file__}')"
10699
107-
108100 start = time .perf_counter ()
109101 result = proxy .execute (code )
110102 duration = (time .perf_counter () - start ) * 1000
111103
112104 if result .get ("success" ):
113105 stdout = result .get ("stdout" , "" ).strip ()
114- # Parse output "VERSION=x.y.z|PATH=..."
115106 try :
116107 parts = stdout .split ("|" )
117108 actual_version = parts [0 ].split ("=" )[1 ]
118109 actual_path = parts [1 ].split ("=" )[1 ]
119-
110+
120111 safe_print (f" - Version: { actual_version } " )
121112 safe_print (f" - Path: { actual_path } " )
122113 safe_print (f" - Latency: { duration :.2f} ms" )
123114
124115 if actual_version != target_version :
125- safe_print (f" ❌ MISMATCH! Expected { target_version } " )
116+ safe_print (f" ❌ MISMATCH! Expected { target_version } , got { actual_version } " )
126117 return False
127118 return True
128119 except IndexError :
@@ -137,7 +128,7 @@ def run_fast_test():
137128 cm = ConfigManager (suppress_init_messages = True )
138129 core = OmnipkgCore (cm )
139130
140- # 1. Fast Setup (Skipping installs if present)
131+ # 1. Fast Setup
141132 fast_setup (core )
142133
143134 # 2. Daemon Check
@@ -147,7 +138,7 @@ def run_fast_test():
147138 print_header ("STEP 2: Daemon Verification" )
148139 results = {}
149140
150- # Test Main
141+ # Test Main — use whatever version is actually there
151142 print (f"\n --- Testing Main Version ({ DEFAULT_RICH_VERSION } ) ---" )
152143 results ["Main" ] = test_version_via_daemon (DEFAULT_RICH_VERSION , client , is_bubble = False )
153144
0 commit comments