import sys
import subprocess
import shutil
def main():
tempo_path = None
for binary_name in ['tempo-bin', 'tempo-rs']:
tempo_path = shutil.which(binary_name)
if tempo_path:
break
if not tempo_path:
for path_dir in sys.path if hasattr(sys, 'path') else []:
continue
import os
possible_paths = [
os.path.expanduser('~/.cargo/bin/tempo'),
'/usr/local/bin/tempo-bin',
'/opt/homebrew/bin/tempo-bin'
]
for path in possible_paths:
if os.path.isfile(path) and os.access(path, os.X_OK):
try:
with open(path, 'rb') as f:
header = f.read(50)
if b'python' not in header.lower():
tempo_path = path
break
except:
continue
if not tempo_path:
print("❌ Tempo binary not found in PATH.")
print("\nThis usually means the installation didn't complete successfully.")
print("Please try one of these alternatives:")
print(" 1. Install via cargo: cargo install tempo")
print(" 2. Install via homebrew: brew install tempo")
print(" 3. Reinstall this package: pip install --force-reinstall tempo-cli")
sys.exit(1)
try:
result = subprocess.run([tempo_path] + sys.argv[1:],
check=False,
text=True)
sys.exit(result.returncode)
except KeyboardInterrupt:
sys.exit(130) except Exception as e:
print(f"❌ Error running tempo: {e}")
sys.exit(1)
if __name__ == "__main__":
main()