UV Binary Test¶
Demo Status: Verified
This demo validates OS-level binary path manipulation (PATH injection).
This demo demonstrates a capability that most Python virtual environment managers cannot perform: swapping binary executables on the fly without changing the global system configuration.
It uses the high-performance uv package manager as a test case, proving that OmniPkg can manage multiple conflicting versions of a binary tool simultaneously.
Usage¶
To run this demo locally:
Try it now: Cloud users can click the play button to run this demo instantly:
What You’ll Learn¶
- PATH Injection: How
omnipkgLoadertemporarily prepends bubble directories to thePATHenvironment variable. - Binary Isolation: How distinct binary versions (
0.9.5,0.4.30,0.5.11) coexist on the same disk. - Context Context: How the active Python context can “see” a different binary version than the rest of the OS.
The Code¶
This script verifies that we can execute different versions of the uv binary depending on which context is active.
from omnipkg.loader import omnipkgLoader
import subprocess
import shutil
# 1. Setup Main Environment (e.g. uv 0.9.5)
# This is the version installed in the main site-packages
run_command(["uv", "--version"])
# Output: uv 0.9.5
# 2. Test Swapped Execution (e.g. uv 0.4.30)
# We use the omnipkgLoader context manager to activate a bubble
with omnipkgLoader("uv==0.4.30", force_activation=True):
# Debug: Check which binary the OS sees
print(f"Which uv: {shutil.which('uv')}")
# Output: .../.omnipkg_versions/uv-0.4.30/bin/uv
# Execute it!
subprocess.run(["uv", "--version"])
# Output: uv 0.4.30
# 3. Context Exit
# Outside the block, we are back to the main version
subprocess.run(["uv", "--version"])
# Output: uv 0.9.5
Live Execution Log¶
This log proves that the PATH variable is being modified in real-time (look at the “First 3 PATH entries” debug line).
(evocoder_env) minds3t@aiminingrig:~/omnipkg$ omnipkg demo 2
================================================================================
đ đ¨ OMNIPKG UV BINARY STRESS TEST (NO CLEANUP) đ¨
================================================================================
================================================================================
đ STEP 1: Environment Setup & Cleanup
================================================================================
âšī¸ 'uv' not found in main environment. Installing a baseline version (0.9.5)...
â
Environment prepared
================================================================================
đ STEP 2: Creating Test Bubbles for Older Versions
================================================================================
â
Bubble for uv==0.4.30 already exists.
â
Bubble for uv==0.5.11 already exists.
================================================================================
đ STEP 3: Comprehensive UV Version Testing
================================================================================
--- Testing Main Environment (uv==0.9.5) ---
đŦ Testing binary at: .../bin/uv
â
Main environment version: 0.9.5
--- Testing Bubble (uv==0.4.30) ---
đ§ Testing swapped binary execution via omnipkgLoader...
đ First 3 PATH entries: [
'.../site-packages/.omnipkg_versions/uv-0.4.30/bin', <-- INJECTED!
'/home/minds3t/.local/bin',
'/home/minds3t/miniconda3/envs/evocoder_env/bin'
]
đ Which uv: .../.omnipkg_versions/uv-0.4.30/bin/uv
đ Version via PATH: 0.4.30
â
Swapped binary reported: 0.4.30
đ¯ Swapped binary test: PASSED
--- Testing Bubble (uv==0.5.11) ---
đ§ Testing swapped binary execution via omnipkgLoader...
đ First 3 PATH entries: [
'.../site-packages/.omnipkg_versions/uv-0.5.11/bin', <-- INJECTED!
...
]
đ Version via PATH: 0.5.11
â
Swapped binary reported: 0.5.11
đ¯ Swapped binary test: PASSED
================================================================================
đ FINAL TEST RESULTS
================================================================================
đ Test Summary:
bubble-0.4.30 : â
PASSED
bubble-0.5.11 : â
PASSED
main-0.9.5 : â
PASSED
đđđ ALL UV BINARY TESTS PASSED! đđđ
How It Works¶
- Binary Detection: OmniPkg detects that
uvprovides a binary executable (by checking thebin/directory in the wheel). - Loader Activation: When
omnipkgLoader("uv==0.4.30")is called, it finds the isolated bubble path. - PATH Manipulation: It prepends the bubble’s
bin/directory toos.environ["PATH"]. - Process Inheritance: Any
subprocess.runcalls made inside that block inherit the modified environment, causing the OS to find the bubbled binary first.