| #!/usr/bin/env python3 | |
| """ | |
| Install private dependencies using environment variables. | |
| This script should be run before the main application starts. | |
| """ | |
| import os | |
| import subprocess | |
| import sys | |
| def install_private_repos(): | |
| """Install private repositories using environment variables.""" | |
| # Get GitHub token from environment variable | |
| github_token = os.getenv("GITHUB_TOKEN") | |
| if not github_token: | |
| print("Warning: GITHUB_TOKEN environment variable not found.") | |
| print("Private repository 'olmoasr' will not be installed.") | |
| print( | |
| "Please set GITHUB_TOKEN in your environment or HuggingFace Spaces secrets." | |
| ) | |
| return False | |
| # Install olmoasr from private repository | |
| repo_url = f"git+https://{github_token}@github.com/allenai/OLMoASR.git" | |
| try: | |
| print("Installing olmoasr from private repository...") | |
| subprocess.check_call([sys.executable, "-m", "pip", "install", repo_url]) | |
| print("Successfully installed olmoasr!") | |
| return True | |
| except subprocess.CalledProcessError as e: | |
| print(f"Error installing olmoasr: {e}") | |
| print("Please check your GITHUB_TOKEN and repository access.") | |
| return False | |
| if __name__ == "__main__": | |
| install_private_repos() | |