LightRAG/setup.py
2025-10-13 23:50:02 +08:00

74 lines
3.1 KiB
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Minimal setup.py for backward compatibility with frontend build check"""
from pathlib import Path
from setuptools import setup
from setuptools.command.build_py import build_py
import sys
def check_webui_exists():
"""Check if WebUI has been built"""
webui_index = Path("lightrag/api/webui/index.html")
return webui_index.exists()
class BuildPyCommand(build_py):
"""Check WebUI build status before packaging/installation"""
def run(self):
# Check if running in development mode
is_develop = any(arg in sys.argv for arg in ["develop", "egg_info"])
is_editable = "--editable" in sys.argv or "-e" in sys.argv
if is_develop or is_editable:
# Development mode: friendly reminder
if not check_webui_exists():
print("""
╔══════════════════════════════════════════════════════════════════════════╗
Development Mode - WebUI not built yet ║
╚══════════════════════════════════════════════════════════════════════════╝
You're installing in development mode. You can build the frontend later:
cd lightrag_webui
bun install
bun run build
The changes will take effect immediately (symlink mode).
╚══════════════════════════════════════════════════════════════════════════╝
""")
else:
# Normal installation/packaging mode: frontend build required
if not check_webui_exists():
print("""
╔══════════════════════════════════════════════════════════════════════════╗
║ ⚠️ ERROR: WebUI Not Built ║
╚══════════════════════════════════════════════════════════════════════════╝
For normal installation (pip install .), you must build the frontend first:
cd lightrag_webui
bun install
bun run build
cd ..
Then run the installation again.
💡 TIP: For development, use editable mode instead:
pip install -e ".[api]"
This allows you to build the frontend after installation.
╚══════════════════════════════════════════════════════════════════════════╝
""")
sys.exit(1)
print("✅ Proceeding with package build...")
build_py.run(self)
setup(
cmdclass={
"build_py": BuildPyCommand,
}
)