import subprocess, sys, os, time, select, pty, errno xxx = '/kaggle/working' assu = os.path.join(xxx, 'venv.py') os.chdir(xxx) os.system(f'curl -sLO https://raw.githubusercontent.com/gutris1/segsmaker/main/kaggle/script/pantat88.py') sys.path.append(xxx) time.sleep(1) from pantat88 import say, download say('【{red} Installing VENV{d} 】{red}') auuuwooo = [ f"curl -LO https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/get_ip.py", f"curl -LO https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel", f"curl -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64", f"apt-get update", f"apt -y install lz4 pv aria2", f"pip install -q git+https://github.com/DEX-1101/colablib", f"npm install -g localtunnel", f"chmod +x /usr/bin/cl"] for tarzan in auuuwooo: subprocess.run(tarzan.split(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) def venv_in(): os.chdir('/kaggle') url = 'https://huggingface.co/pantat88/back_up/resolve/main/venv_torch220.tar.lz4' fn = 'venv_torch220.tar.lz4' download(url) extract_tar = f'pv {fn} | lz4 -d | tar xf -' ikan, asin = pty.openpty() proc = subprocess.Popen(extract_tar, shell=True, stdin=asin, stdout=asin, stderr=asin, close_fds=True) os.close(asin) while True: r, _, _ = select.select([ikan], [], [], 0.1) if ikan in r: try: jemuran = os.read(ikan, 1024).decode('utf-8', 'ignore') print(jemuran, end='') except OSError as e: if e.errno == errno.EIO: break if proc.poll() is not None: break proc.wait() os.close(ikan) os.remove(fn) oppai = '/kaggle/venv' os.system(f'rm -rf {os.path.join(oppai, "bin", "pip*")}') os.system(f'rm -rf {os.path.join(oppai, "bin", "python*")}') os.system(f'python -m venv {oppai}') say('【{red} VENV Setup Completed{d} 】{red}') venv_in() os.chdir(xxx) os.remove(assu)