Transformers
Inference Endpoints
pantat88 commited on
Commit
5809507
·
verified ·
1 Parent(s): 09e9f7d

Create venv220.py

Browse files
Files changed (1) hide show
  1. venv220.py +105 -0
venv220.py ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ import select
3
+ import errno
4
+ import pty
5
+ import sys
6
+ import os
7
+ import re
8
+
9
+ xxx = "/kaggle/working"
10
+ zzz = "/kaggle/working/asd"
11
+
12
+ os.system('apt-get update > /dev/null 2>&1')
13
+ os.system('apt -y install lz4 pv aria2 > /dev/null 2>&1')
14
+
15
+ os.system(f'curl -sLo {xxx}/pantat88.py https://raw.githubusercontent.com/gutris1/segsmaker/main/kaggle/script/pantat88.py')
16
+ os.system(f'curl -sLo {xxx}/nenen88.py https://huggingface.co/pantat88/ui/resolve/main/nenen88.py')
17
+ sys.path.append(xxx)
18
+
19
+ def venv_in():
20
+ from pantat88 import say
21
+ os.chdir('/kaggle')
22
+ say('【 {red} Installing VENV {d} 】 {red}')
23
+
24
+ url = 'https://huggingface.co/pantat88/back_up/resolve/main/venv_torch220.tar.lz4'
25
+ fn = 'venv_torch220.tar.lz4'
26
+ fc = f"aria2c --console-log-level=error --summary-interval=1 -c -x16 -s16 -k1M -j5 '{url}' -o '{fn}'"
27
+ woiii, appaa = pty.openpty()
28
+ qqqqq = subprocess.Popen(fc, shell=True, stdin=appaa, stdout=appaa, stderr=subprocess.STDOUT, close_fds=True)
29
+ os.close(appaa)
30
+
31
+ malam = ""
32
+ while True:
33
+ r, _, _ = select.select([woiii], [], [], 0.1)
34
+ if woiii in r:
35
+ try:
36
+ petualangan = os.read(woiii, 8192).decode()
37
+ malam += petualangan
38
+ for minggu in petualangan.splitlines():
39
+ if re.match(r'\[#\w{6}\s.*\]', minggu):
40
+ sys.stdout.write("\r" + " "*80 + "\r")
41
+ sys.stdout.write(f" {minggu}")
42
+ sys.stdout.flush()
43
+ break
44
+
45
+ except OSError as e:
46
+ if e.errno == errno.EIO:
47
+ break
48
+
49
+ if qqqqq.poll() is not None and not r:
50
+ break
51
+
52
+ kemarin = malam.find("Download Results:")
53
+ if kemarin != -1:
54
+ hhhhh = malam[kemarin:]
55
+ jjjjj = hhhhh.splitlines()
56
+ kkkkk = False
57
+ for ggggg in jjjjj:
58
+ if ggggg.strip().startswith("======+====+==========="):
59
+ kkkkk = True
60
+ print("\n" + f" {ggggg}")
61
+ continue
62
+ elif ggggg.strip().startswith("Status Legend:"):
63
+ break
64
+ elif kkkkk:
65
+ print(f" {ggggg}")
66
+
67
+ qqqqq.wait()
68
+ os.close(woiii)
69
+
70
+ extract_tar = f'pv {fn} | lz4 -d | tar xf -'
71
+
72
+ ikan, asin = pty.openpty()
73
+ proc = subprocess.Popen(extract_tar, shell=True, stdin=asin, stdout=asin, stderr=asin, close_fds=True)
74
+ os.close(asin)
75
+
76
+ while True:
77
+ r, _, _ = select.select([ikan], [], [], 0.1)
78
+ if ikan in r:
79
+ try:
80
+ jemuran = os.read(ikan, 1024).decode('utf-8', 'ignore')
81
+ print(jemuran, end='')
82
+ except OSError as e:
83
+ if e.errno == errno.EIO:
84
+ break
85
+ if proc.poll() is not None:
86
+ break
87
+
88
+ proc.wait()
89
+ os.close(ikan)
90
+ if os.path.exists(fn):
91
+ os.remove(fn)
92
+ else:
93
+ print(f"Warning: File {fn} not found, skipping removal.")
94
+
95
+
96
+ oppai = '/kaggle/venv'
97
+ os.system(f'rm -rf {os.path.join(oppai, "bin", "pip*")}')
98
+ os.system(f'rm -rf {os.path.join(oppai, "bin", "python*")}')
99
+ os.system(f'python -m venv {oppai}')
100
+ say('【 {red} Setup Completed {d} 】 {red}')
101
+
102
+ if __name__ == '__main__':
103
+ venv_in()
104
+ assu = os.path.join(xxx, 'venv.py')
105
+ os.remove(assu)