Files
ds-fire-fighter/test.py
T
2025-04-09 00:53:16 +01:00

61 lines
1.6 KiB
Python

import subprocess
import re
# List of packages you want to include
packages = [
"openai",
"pandas",
"python-dotenv",
"fastapi",
"uvicorn",
"langchain-community",
"langchain-openai",
"pydantic",
"pypdf",
"pypandoc",
"plum-dispatch==1.7.4", # You specified exact version here
"scikit-learn",
"werkzeug",
"python-multipart",
"langgraph",
"tiktoken",
"langchainhub",
"chromadb",
"langchain",
"langchain-text-splitters",
"beautifulsoup4",
"langchain-core",
"PyPDF2",
"reportlab",
"python-docx"
]
# Get all installed packages with versions
result = subprocess.run(["pip", "freeze"], capture_output=True, text=True)
installed_packages = result.stdout.strip().split('\n')
# Create a dictionary of package names to their full name with version
package_dict = {}
for pkg in installed_packages:
if '==' in pkg:
name = pkg.split('==')[0].lower()
package_dict[name] = pkg
# Write only the requested packages to requirements.txt
with open('requirements.txt', 'w') as f:
for package in packages:
# Handle cases where version is already specifixed
if '==' in package:
f.write(f"{package}\n")
continue
# Try to find the package in installed packages
pkg_name = package.lower()
if pkg_name in package_dict:
f.write(f"{package_dict[pkg_name]}\n")
else:
# If not found, just write the package name
f.write(f"{package}\n")
print(f"Warning: {package} not found in installed packages")
print("requirements.txt has been generated.")