3030 sys .exit (1 )
3131
3232# --- Test Configuration ---
33- # Fallback version ONLY if uv is not installed at all.
34- MAIN_UV_VERSION_FALLBACK = "0.9.5" # A recent, known-good version
33+ MAIN_UV_VERSION_FALLBACK = "0.9.5"
3534BUBBLE_VERSIONS_TO_TEST = ["0.4.30" , "0.5.11" ]
3635
36+ # Platform-aware binary name
37+ UV_BIN_NAME = "uv.exe" if sys .platform == "win32" else "uv"
38+
3739
3840def print_header (title ):
3941 safe_print ("\n " + "=" * 80 )
@@ -42,20 +44,10 @@ def print_header(title):
4244
4345
4446def parse_uv_version (version_output ):
45- """
46- Parse uv version from output, handling different formats.
47-
48- Examples:
49- - "uv 0.4.30 (2024-11-04)" -> "0.4.30"
50- - "uv 0.5.11 (commit abc123)" -> "0.5.11"
51- - "0.10.2" -> "0.10.2"
52- """
53- # Split the output and look for version pattern (X.Y.Z)
5447 import re
5548 match = re .search (r'\b(\d+\.\d+\.\d+)\b' , version_output )
5649 if match :
5750 return match .group (1 )
58- # Fallback: return the whole thing
5951 return version_output .strip ()
6052
6153
@@ -77,17 +69,28 @@ def run_command(command, check=True):
7769 )
7870
7971
80- def setup_environment ( omnipkg_core : OmnipkgCore ) :
72+ def find_uv_binary ( bubble_path : Path ) -> Path :
8173 """
82- (FLEXIBLE) Prepares the environment by detecting the existing `uv` version
83- or installing a safe fallback if it's missing .
74+ Find the uv binary in a bubble's bin dir, handling Windows .exe extension.
75+ Returns the Path if found, raises FileNotFoundError otherwise .
8476 """
85- print_header ("STEP 1: Environment Setup & Cleanup" )
77+ bin_dir = bubble_path / "bin"
78+ # Try exact platform name first, then case-insensitive glob as fallback
79+ for candidate in [UV_BIN_NAME , "uv.EXE" , "uv" ]:
80+ p = bin_dir / candidate
81+ if p .exists ():
82+ return p
83+ # Last resort: glob for anything named uv* in bin/
84+ matches = list (bin_dir .glob ("uv*" ))
85+ if matches :
86+ return matches [0 ]
87+ raise FileNotFoundError (f"No uv binary found in { bin_dir } " )
8688
87- # REMOVED: Cleanup of old demo bubbles
89+
90+ def setup_environment (omnipkg_core : OmnipkgCore ):
91+ print_header ("STEP 1: Environment Setup & Cleanup" )
8892 safe_print (" ⚠️ Skipping cleanup - files will be preserved for inspection" )
8993
90- # --- THIS IS YOUR CORRECT, FLEXIBLE DETECTION LOGIC ---
9194 main_uv_version = None
9295 try :
9396 main_uv_version = get_version ("uv" )
@@ -100,28 +103,21 @@ def setup_environment(omnipkg_core: OmnipkgCore):
100103 )
101104 omnipkg_core .smart_install ([f"uv=={ MAIN_UV_VERSION_FALLBACK } " ])
102105 main_uv_version = MAIN_UV_VERSION_FALLBACK
103- # --- END OF DETECTION LOGIC ---
104106
105107 force_omnipkg_rescan (omnipkg_core , "uv" )
106108 safe_print ("✅ Environment prepared" )
107109 return main_uv_version
108110
109111
110112def create_test_bubbles (omnipkg_core : OmnipkgCore ):
111- """
112- (CORRECTED) Create test bubbles for older UV versions using the
113- direct bubble creation method to bypass satisfaction checks.
114- """
115113 print_header ("STEP 2: Creating Test Bubbles for Older Versions" )
116114
117- # Get the Python version string for the current context
118115 python_context_version = f"{ sys .version_info .major } .{ sys .version_info .minor } "
119116
120117 for version in BUBBLE_VERSIONS_TO_TEST :
121118 bubble_name = f"uv-{ version } "
122119 bubble_path = omnipkg_core .multiversion_base / bubble_name
123120
124- # Only create if it doesn't already exist from a previous failed run
125121 if bubble_path .exists ():
126122 safe_print (
127123 f" ✅ Bubble for uv=={ version } already exists. Skipping creation."
@@ -130,15 +126,12 @@ def create_test_bubbles(omnipkg_core: OmnipkgCore):
130126
131127 safe_print (f" 🫧 Force-creating bubble for uv=={ version } ..." )
132128 try :
133- # --- THIS IS THE CRITICAL FIX ---
134- # Use the direct, forceful bubble creation method
135129 success = omnipkg_core .bubble_manager .create_isolated_bubble (
136130 "uv" , version , python_context_version = python_context_version
137131 )
138132
139133 if success :
140134 safe_print (_ (' ✅ Bubble created: {}' ).format (bubble_name ))
141- # Also ensure the KB knows about this new bubble
142135 omnipkg_core .rebuild_package_kb ([f"uv=={ version } " ])
143136 else :
144137 safe_print (f" ❌ Failed to create bubble for uv=={ version } " )
@@ -149,7 +142,6 @@ def create_test_bubbles(omnipkg_core: OmnipkgCore):
149142
150143
151144def force_omnipkg_rescan (omnipkg_core , package_name ):
152- """Tells omnipkg to forcibly rescan a specific package's metadata."""
153145 safe_print (f" 🧠 Forcing omnipkg KB rebuild for { package_name } ..." )
154146 try :
155147 omnipkg_core .rebuild_package_kb ([package_name ])
@@ -170,19 +162,21 @@ def inspect_bubble_structure(bubble_path):
170162 else :
171163 safe_print (" ⚠️ No dist-info found" )
172164
173- scripts_dir = bubble_path / "bin"
174- if scripts_dir .exists ():
175- items = list (scripts_dir .iterdir ())
165+ bin_dir = bubble_path / "bin"
166+ if bin_dir .exists ():
167+ items = list (bin_dir .iterdir ())
176168 safe_print (f" ✅ Found bin directory with { len (items )} items" )
177- uv_bin = scripts_dir / "uv"
178- if uv_bin .exists ():
179- safe_print (_ (' ✅ Found uv binary: {}' ).format (uv_bin ))
169+ # Platform-aware binary check
170+ try :
171+ uv_bin = find_uv_binary (bubble_path )
172+ safe_print (_ (' ✅ Found uv binary: {}' ).format (uv_bin .name ))
180173 if os .access (uv_bin , os .X_OK ):
181174 safe_print (" ✅ Binary is executable" )
182175 else :
183176 safe_print (" ⚠️ Binary is not executable" )
184- else :
185- safe_print (" ⚠️ No uv binary in bin/" )
177+ except FileNotFoundError :
178+ safe_print (f" ⚠️ No uv binary found in bin/ (looked for { UV_BIN_NAME } )" )
179+ safe_print (f" 📋 bin/ contents: { [x .name for x in items ]} " )
186180 else :
187181 safe_print (" ⚠️ No bin directory found" )
188182
@@ -200,14 +194,18 @@ def test_swapped_binary_execution(expected_version, config, omnipkg_core):
200194 safe_print (" 🔧 Testing swapped binary execution via omnipkgLoader..." )
201195
202196 bubble_path = omnipkg_core .multiversion_base / f"uv-{ expected_version } "
203- bubble_binary = bubble_path / "bin" / "uv"
197+
198+ # Platform-aware binary path
199+ try :
200+ bubble_binary = find_uv_binary (bubble_path )
201+ except FileNotFoundError as e :
202+ safe_print (f" ❌ Cannot find bubble binary: { e } " )
203+ return False
204204
205205 try :
206206 with omnipkgLoader (
207207 f"uv=={ expected_version } " , config = config , quiet = True , force_activation = True
208208 ):
209-
210- # Debug: Show PATH and which binary is found
211209 path_entries = os .environ .get ("PATH" , "" ).split (os .pathsep )
212210 safe_print (_ (' 🔍 First 3 PATH entries: {}' ).format (path_entries [:3 ]))
213211 safe_print (_ (' 🔍 Which uv: {}' ).format (shutil .which ('uv' )))
@@ -244,7 +242,6 @@ def test_swapped_binary_execution(expected_version, config, omnipkg_core):
244242
245243
246244def run_comprehensive_test ():
247- """Main function to orchestrate the test with robust strategy and version handling."""
248245 print_header ("🚨 OMNIPKG UV BINARY STRESS TEST (NO CLEANUP) 🚨" )
249246
250247 config_manager = None
@@ -275,14 +272,12 @@ def run_comprehensive_test():
275272 # Test Main Environment
276273 print_subheader (_ ('Testing Main Environment (uv=={})' ).format (main_uv_version_to_test ))
277274 try :
278- # Use shutil.which to find uv in PATH (handles .exe on Windows)
279275 uv_binary_path = shutil .which ("uv" )
280-
276+
281277 if not uv_binary_path :
282- # Fallback: try to construct path manually
283278 python_exe = config_manager .config .get ("python_executable" , sys .executable )
284279 scripts_dir = Path (python_exe ).parent / ("Scripts" if sys .platform == "win32" else "bin" )
285- uv_binary_path = scripts_dir / ( "uv.exe" if sys . platform == "win32" else "uv" )
280+ uv_binary_path = scripts_dir / UV_BIN_NAME
286281 if not uv_binary_path .exists ():
287282 raise FileNotFoundError (f"UV binary not found in { scripts_dir } " )
288283
@@ -331,7 +326,6 @@ def run_comprehensive_test():
331326 else :
332327 safe_print ("\n 🎉🎉🎉 ALL UV BINARY TESTS PASSED! 🎉🎉🎉" )
333328
334- # REMOVED: All cleanup code
335329 safe_print ("\n 📁 Bubble files preserved for inspection" )
336330 safe_print (_ ('📍 Location: {}' ).format (omnipkg_core .multiversion_base ))
337331
@@ -342,7 +336,6 @@ def run_comprehensive_test():
342336 traceback .print_exc ()
343337 return False
344338 finally :
345- # Only restore config, NO file cleanup
346339 if config_manager and original_strategy and original_strategy != "stable-main" :
347340 safe_print (_ ('\n 🔄 Restoring original install strategy: {}' ).format (original_strategy ))
348341 config_manager .set ("install_strategy" , original_strategy )
0 commit comments