Skip to content

Commit

Permalink
v3.4.5 - linux install script
Browse files Browse the repository at this point in the history
  • Loading branch information
BBC-Esq authored Feb 13, 2024
1 parent d4ba83e commit f9d61e2
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/setup_linux.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
import subprocess
import sys

if sys.version_info.major != 3 or sys.version_info.minor not in [10, 11]:
print("Only Python 3.10 or 3.11 are supported.")
sys.exit(1)

def is_package_installed(package_name):
result = subprocess.run(['dpkg', '-l', package_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return result.returncode == 0

def install_system_package(package_name):
if not is_package_installed(package_name):
subprocess.run(['sudo', 'apt-get', 'install', package_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

def check_gpu():
try:
nvidia_smi = subprocess.run(['nvidia-smi'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Expand Down Expand Up @@ -43,6 +55,17 @@ def install_packages(gpu_type):
else: # cpu
subprocess.run(f"{base_cmd} torch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 --index-url https://download.pytorch.org/whl/cpu", shell=True)

def install_python_requirements():
subprocess.run(['pip3', 'install', '-r', 'requirements.txt'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

def run_python_script(script_name):
subprocess.run(['python', script_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

if __name__ == "__main__":
install_system_package('portaudio19-dev')
install_system_package('python3-dev')
install_system_package('libxcb-cursor0')
gpu_type = check_gpu()
install_packages(gpu_type)
install_python_requirements()
run_python_script('replace_pdf.py')

0 comments on commit f9d61e2

Please sign in to comment.