Update venv.py
Browse files
venv.py
CHANGED
@@ -1,10 +1,11 @@
|
|
1 |
-
import subprocess, sys, os, time,
|
2 |
-
from IPython.display import clear_output
|
3 |
from IPython import get_ipython
|
4 |
from pathlib import Path
|
5 |
|
6 |
xxx = Path('/kaggle/working')
|
7 |
script = xxx / 'venv.py'
|
|
|
8 |
vnv = Path('/kaggle/venv')
|
9 |
url = 'https://huggingface.co/pantat88/back_up/resolve/main/venv.tar.lz4'
|
10 |
fn = Path(url).name
|
@@ -12,23 +13,49 @@ fn = Path(url).name
|
|
12 |
os.chdir(xxx)
|
13 |
sys.path.append(str(xxx))
|
14 |
|
|
|
15 |
get_ipython().system('curl -sLO https://raw.githubusercontent.com/gutris1/segsmaker/main/kaggle/script/pantat88.py')
|
|
|
16 |
time.sleep(1)
|
17 |
|
18 |
from pantat88 import say, download
|
19 |
say('【{red} Installing VENV{d} 】{red}')
|
20 |
|
21 |
req_list = [
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
28 |
|
29 |
for items in req_list:
|
30 |
subprocess.run(items.split(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
def venv_install():
|
33 |
os.chdir('/kaggle')
|
34 |
download(url)
|
@@ -43,6 +70,8 @@ def venv_install():
|
|
43 |
get_ipython().system(f'{vnv}/bin/python3 -m pip install -q --upgrade pip')
|
44 |
|
45 |
venv_install()
|
46 |
-
|
|
|
|
|
47 |
script.unlink()
|
48 |
os.chdir(xxx)
|
|
|
1 |
+
import subprocess, sys, os, time, errno
|
2 |
+
from IPython.display import clear_output, Image, display
|
3 |
from IPython import get_ipython
|
4 |
from pathlib import Path
|
5 |
|
6 |
xxx = Path('/kaggle/working')
|
7 |
script = xxx / 'venv.py'
|
8 |
+
img = xxx / "loading.png"
|
9 |
vnv = Path('/kaggle/venv')
|
10 |
url = 'https://huggingface.co/pantat88/back_up/resolve/main/venv.tar.lz4'
|
11 |
fn = Path(url).name
|
|
|
13 |
os.chdir(xxx)
|
14 |
sys.path.append(str(xxx))
|
15 |
|
16 |
+
get_ipython().system('curl -sLO https://raw.githubusercontent.com/gutris1/segsmaker/main/script/loading.png')
|
17 |
get_ipython().system('curl -sLO https://raw.githubusercontent.com/gutris1/segsmaker/main/kaggle/script/pantat88.py')
|
18 |
+
display(Image(filename=str(img)))
|
19 |
time.sleep(1)
|
20 |
|
21 |
from pantat88 import say, download
|
22 |
say('【{red} Installing VENV{d} 】{red}')
|
23 |
|
24 |
req_list = [
|
25 |
+
"curl -LO https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel",
|
26 |
+
"curl -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64",
|
27 |
+
"apt-get update",
|
28 |
+
"apt -y install lz4 pv aria2",
|
29 |
+
"pip install -q cloudpickle",
|
30 |
+
"chmod +x /usr/bin/cl"
|
31 |
+
]
|
32 |
|
33 |
for items in req_list:
|
34 |
subprocess.run(items.split(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
35 |
|
36 |
+
def she_bang():
|
37 |
+
vnv_bin = vnv / 'bin'
|
38 |
+
old_shebang = b'#!/home/studio-lab-user/tmp/venv/bin/python3\n'
|
39 |
+
new_shebang = f"#!{vnv}/bin/python3\n"
|
40 |
+
|
41 |
+
for script in vnv_bin.glob('*'):
|
42 |
+
if script.is_file():
|
43 |
+
try:
|
44 |
+
with open(script, 'r+b') as file:
|
45 |
+
lines = file.readlines()
|
46 |
+
if lines and lines[0] == old_shebang:
|
47 |
+
lines[0] = new_shebang.encode('utf-8')
|
48 |
+
file.seek(0)
|
49 |
+
file.writelines(lines)
|
50 |
+
file.truncate()
|
51 |
+
print(f"Updated shebang in {script.name} to {new_shebang.strip()}")
|
52 |
+
|
53 |
+
except OSError as e:
|
54 |
+
if e.errno == 26:
|
55 |
+
print(f"Skipped {script.name}")
|
56 |
+
else:
|
57 |
+
print(f"Failed to update {script.name}: {e}")
|
58 |
+
|
59 |
def venv_install():
|
60 |
os.chdir('/kaggle')
|
61 |
download(url)
|
|
|
70 |
get_ipython().system(f'{vnv}/bin/python3 -m pip install -q --upgrade pip')
|
71 |
|
72 |
venv_install()
|
73 |
+
she_bang()
|
74 |
+
|
75 |
+
clear_output(wait=True)
|
76 |
script.unlink()
|
77 |
os.chdir(xxx)
|