AshanGimhana
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,31 @@
|
|
1 |
import os
|
|
|
2 |
|
3 |
os.system("pip install gradio==3.50")
|
4 |
|
5 |
-
if not os.path.exists('ninja-linux.zip'):
|
6 |
-
os.system("wget https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip")
|
7 |
-
os.system("unzip ninja-linux.zip -d ninja") # Unzip it to a local directory
|
8 |
|
9 |
-
# Set Ninja to the PATH
|
10 |
-
os.environ['PATH'] = os.getcwd() + '/ninja:' + os.environ['PATH']
|
11 |
|
12 |
-
#
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
|
16 |
from argparse import Namespace
|
|
|
1 |
import os
|
2 |
+
import subprocess
|
3 |
|
4 |
os.system("pip install gradio==3.50")
|
5 |
|
|
|
|
|
|
|
6 |
|
|
|
|
|
7 |
|
8 |
+
# Function to download and install Ninja
|
9 |
+
def install_ninja():
|
10 |
+
# Check if ninja is already installed
|
11 |
+
if subprocess.run(["ninja", "--version"], capture_output=True).returncode != 0:
|
12 |
+
print("Ninja not found, downloading...")
|
13 |
+
# Download Ninja
|
14 |
+
subprocess.run(["wget", "https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-linux.zip"], check=True)
|
15 |
+
|
16 |
+
# Unzip it
|
17 |
+
subprocess.run(["unzip", "ninja-linux.zip"], check=True)
|
18 |
+
|
19 |
+
# Move Ninja to a directory in PATH
|
20 |
+
os.rename("ninja", "/usr/local/bin/ninja") # You may need to change this path
|
21 |
+
print("Ninja installed successfully.")
|
22 |
+
|
23 |
+
# Call the function to install Ninja
|
24 |
+
install_ninja()
|
25 |
+
|
26 |
+
# Now, you can check if Ninja is installed
|
27 |
+
os.environ["PATH"] += os.pathsep + "/usr/local/bin"
|
28 |
+
print("Ninja version:", subprocess.run(["ninja", "--version"], capture_output=True).stdout.decode().strip())
|
29 |
|
30 |
|
31 |
from argparse import Namespace
|