ColiFormer / install_cai.py
saketh11's picture
Fix CAI installation with Dockerfile approach
2592750
#!/usr/bin/env python3
"""
Install CAI package with workaround for wheel naming issues.
This script installs the CAI package using --no-use-pep517 to avoid
the dynamic wheel naming problem that occurs with pyproject.toml builds.
"""
import subprocess
import sys
import os
def install_cai():
"""Install CAI package with legacy setup.py build system."""
print("Installing CAI package...")
# CAI repository URL and commit
cai_url = "git+https://github.com/Benjamin-Lee/CodonAdaptationIndex.git@b6e017a92c58829f6a5aec8c26a21262bc2a6610"
try:
# Install with --no-use-pep517 to force legacy setup.py build
cmd = [
sys.executable, "-m", "pip", "install",
"--no-use-pep517",
"--no-cache-dir",
cai_url
]
print(f"Running: {' '.join(cmd)}")
result = subprocess.run(cmd, check=True, capture_output=True, text=True)
print("CAI installation successful!")
print(result.stdout)
return True
except subprocess.CalledProcessError as e:
print(f"CAI installation failed: {e}")
print(f"STDOUT: {e.stdout}")
print(f"STDERR: {e.stderr}")
return False
def verify_installation():
"""Verify CAI package can be imported."""
try:
import CAI
from CAI import CAI as cai_func, relative_adaptiveness
print("βœ… CAI package imported successfully")
return True
except ImportError as e:
print(f"❌ Failed to import CAI: {e}")
return False
if __name__ == "__main__":
print("ColiFormer CAI Package Installer")
print("=" * 40)
# Install CAI
if install_cai():
# Verify installation
if verify_installation():
print("πŸŽ‰ CAI installation completed successfully!")
sys.exit(0)
else:
print("πŸ’₯ CAI installation verification failed!")
sys.exit(1)
else:
print("πŸ’₯ CAI installation failed!")
sys.exit(1)