Spaces:
Sleeping
Sleeping
from git import Repo | |
import os | |
import subprocess | |
import sys | |
GITHUB_PAT = os.getenv('GITHUB_PAT') | |
GIT_USER = os.getenv('GIT_USER') | |
GIT_REPO = os.getenv('GIT_REPO') | |
if GITHUB_PAT: | |
print("GITHUB_PAT set") | |
if not os.path.exists('cloned_repo'): | |
Repo.clone_from(f'https://{GIT_USER}:{GITHUB_PAT}@github.com/{GIT_USER}/{GIT_REPO}.git', './cloned_repo') | |
# Install Python dependencies | |
subprocess.run(['pip', 'install', '-r', 'cloned_repo/requirements.txt']) | |
# Install system-level dependencies if packages.txt exists | |
if os.path.exists('cloned_repo/packages.txt'): | |
with open('cloned_repo/packages.txt') as f: | |
packages = f.read().splitlines() | |
if packages: | |
subprocess.run(['apt-get', 'update']) | |
subprocess.run(['apt-get', 'install', '-y'] + packages) | |
sys.path.insert(0, os.path.abspath('cloned_repo')) | |
# Now you can import your modules correctly | |
import main | |
main.main() |