Spaces:
Running
Running
| import re | |
| used_libs = { | |
| "transformers", "torch", "sentencepiece", "pdfplumber", | |
| "python-docx", "docx2txt", "langdetect", "fpdf", "gradio" | |
| } | |
| with open("requirements.txt", "r", encoding="utf-8") as f: | |
| lines = f.readlines() | |
| cleaned = [] | |
| for line in lines: | |
| pkg = re.split(r"[=<>]", line.strip())[0] | |
| if pkg in used_libs: | |
| cleaned.append(line) | |
| else: | |
| print(f"🧹 Удалено неиспользуемое: {pkg}") | |
| with open("requirements.txt", "w", encoding="utf-8") as f: | |
| f.writelines(cleaned) | |
| print("✅ requirements.txt очищен и обновлён.") | |