File size: 1,278 Bytes
6374b15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
078db05
6374b15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/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()