| 
									
										
										
										
											2024-10-08 10:38:50 +08:00
										 |  |  | import setuptools | 
					
						
							| 
									
										
										
										
											2024-10-25 18:39:55 +05:30
										 |  |  | from pathlib import Path | 
					
						
							| 
									
										
										
										
											2024-10-08 10:38:50 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-26 16:12:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-25 18:39:55 +05:30
										 |  |  | # Reading the long description from README.md | 
					
						
							|  |  |  | def read_long_description(): | 
					
						
							|  |  |  |     try: | 
					
						
							|  |  |  |         return Path("README.md").read_text(encoding="utf-8") | 
					
						
							|  |  |  |     except FileNotFoundError: | 
					
						
							|  |  |  |         return "A description of LightRAG is currently unavailable." | 
					
						
							| 
									
										
										
										
											2024-10-08 10:38:50 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-26 16:12:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-25 18:39:55 +05:30
										 |  |  | # Retrieving metadata from __init__.py | 
					
						
							|  |  |  | def retrieve_metadata(): | 
					
						
							|  |  |  |     vars2find = ["__author__", "__version__", "__url__"] | 
					
						
							|  |  |  |     vars2readme = {} | 
					
						
							|  |  |  |     try: | 
					
						
							|  |  |  |         with open("./lightrag/__init__.py") as f: | 
					
						
							|  |  |  |             for line in f.readlines(): | 
					
						
							|  |  |  |                 for v in vars2find: | 
					
						
							|  |  |  |                     if line.startswith(v): | 
					
						
							| 
									
										
										
										
											2024-10-26 16:12:10 +08:00
										 |  |  |                         line = ( | 
					
						
							|  |  |  |                             line.replace(" ", "") | 
					
						
							|  |  |  |                             .replace('"', "") | 
					
						
							|  |  |  |                             .replace("'", "") | 
					
						
							|  |  |  |                             .strip() | 
					
						
							|  |  |  |                         ) | 
					
						
							| 
									
										
										
										
											2024-10-25 18:39:55 +05:30
										 |  |  |                         vars2readme[v] = line.split("=")[1] | 
					
						
							|  |  |  |     except FileNotFoundError: | 
					
						
							|  |  |  |         raise FileNotFoundError("Metadata file './lightrag/__init__.py' not found.") | 
					
						
							| 
									
										
										
										
											2024-10-26 16:12:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-25 18:39:55 +05:30
										 |  |  |     # Checking if all required variables are found | 
					
						
							|  |  |  |     missing_vars = [v for v in vars2find if v not in vars2readme] | 
					
						
							|  |  |  |     if missing_vars: | 
					
						
							| 
									
										
										
										
											2024-10-26 16:12:10 +08:00
										 |  |  |         raise ValueError( | 
					
						
							|  |  |  |             f"Missing required metadata variables in __init__.py: {missing_vars}" | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-25 18:39:55 +05:30
										 |  |  |     return vars2readme | 
					
						
							| 
									
										
										
										
											2024-10-08 10:38:50 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-26 16:12:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-25 18:39:55 +05:30
										 |  |  | # Reading dependencies from requirements.txt | 
					
						
							|  |  |  | def read_requirements(): | 
					
						
							|  |  |  |     deps = [] | 
					
						
							|  |  |  |     try: | 
					
						
							|  |  |  |         with open("./requirements.txt") as f: | 
					
						
							|  |  |  |             deps = [line.strip() for line in f if line.strip()] | 
					
						
							|  |  |  |     except FileNotFoundError: | 
					
						
							| 
									
										
										
										
											2024-10-26 16:12:10 +08:00
										 |  |  |         print( | 
					
						
							|  |  |  |             "Warning: 'requirements.txt' not found. No dependencies will be installed." | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2024-10-25 18:39:55 +05:30
										 |  |  |     return deps | 
					
						
							| 
									
										
										
										
											2024-10-08 10:38:50 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-26 16:12:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-24 10:18:41 +01:00
										 |  |  | def read_api_requirements(): | 
					
						
							|  |  |  |     api_deps = [] | 
					
						
							|  |  |  |     try: | 
					
						
							|  |  |  |         with open("./lightrag/api/requirements.txt") as f: | 
					
						
							|  |  |  |             api_deps = [line.strip() for line in f if line.strip()] | 
					
						
							|  |  |  |     except FileNotFoundError: | 
					
						
							|  |  |  |         print("Warning: API requirements.txt not found.") | 
					
						
							|  |  |  |     return api_deps | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-05 02:33:26 +08:00
										 |  |  | def read_extra_requirements(): | 
					
						
							|  |  |  |     api_deps = [] | 
					
						
							|  |  |  |     try: | 
					
						
							| 
									
										
										
										
											2025-02-05 02:35:51 +08:00
										 |  |  |         with open("./lightrag/tools/lightrag_visualizer/requirements.txt") as f: | 
					
						
							| 
									
										
										
										
											2025-02-05 02:33:26 +08:00
										 |  |  |             api_deps = [line.strip() for line in f if line.strip()] | 
					
						
							|  |  |  |     except FileNotFoundError: | 
					
						
							|  |  |  |         print("Warning: API requirements.txt not found.") | 
					
						
							|  |  |  |     return api_deps | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-25 18:39:55 +05:30
										 |  |  | metadata = retrieve_metadata() | 
					
						
							|  |  |  | long_description = read_long_description() | 
					
						
							|  |  |  | requirements = read_requirements() | 
					
						
							| 
									
										
										
										
											2024-10-08 10:38:50 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | setuptools.setup( | 
					
						
							| 
									
										
										
										
											2024-10-10 14:58:21 +08:00
										 |  |  |     name="lightrag-hku", | 
					
						
							| 
									
										
										
										
											2024-10-25 18:39:55 +05:30
										 |  |  |     url=metadata["__url__"], | 
					
						
							|  |  |  |     version=metadata["__version__"], | 
					
						
							|  |  |  |     author=metadata["__author__"], | 
					
						
							| 
									
										
										
										
											2024-10-08 10:38:50 +08:00
										 |  |  |     description="LightRAG: Simple and Fast Retrieval-Augmented Generation", | 
					
						
							|  |  |  |     long_description=long_description, | 
					
						
							|  |  |  |     long_description_content_type="text/markdown", | 
					
						
							| 
									
										
										
										
											2024-10-26 16:12:10 +08:00
										 |  |  |     packages=setuptools.find_packages( | 
					
						
							|  |  |  |         exclude=("tests*", "docs*") | 
					
						
							|  |  |  |     ),  # Automatically find packages | 
					
						
							| 
									
										
										
										
											2024-10-08 10:38:50 +08:00
										 |  |  |     classifiers=[ | 
					
						
							| 
									
										
										
										
											2024-10-25 18:39:55 +05:30
										 |  |  |         "Development Status :: 4 - Beta", | 
					
						
							| 
									
										
										
										
											2024-10-08 10:38:50 +08:00
										 |  |  |         "Programming Language :: Python :: 3", | 
					
						
							|  |  |  |         "License :: OSI Approved :: MIT License", | 
					
						
							|  |  |  |         "Operating System :: OS Independent", | 
					
						
							| 
									
										
										
										
											2024-10-25 18:39:55 +05:30
										 |  |  |         "Intended Audience :: Developers", | 
					
						
							|  |  |  |         "Topic :: Software Development :: Libraries :: Python Modules", | 
					
						
							| 
									
										
										
										
											2024-10-08 10:38:50 +08:00
										 |  |  |     ], | 
					
						
							|  |  |  |     python_requires=">=3.9", | 
					
						
							| 
									
										
										
										
											2024-10-25 18:39:55 +05:30
										 |  |  |     install_requires=requirements, | 
					
						
							|  |  |  |     include_package_data=True,  # Includes non-code files from MANIFEST.in | 
					
						
							|  |  |  |     project_urls={  # Additional project metadata | 
					
						
							|  |  |  |         "Documentation": metadata.get("__url__", ""), | 
					
						
							|  |  |  |         "Source": metadata.get("__url__", ""), | 
					
						
							| 
									
										
										
										
											2024-10-26 16:12:10 +08:00
										 |  |  |         "Tracker": f"{metadata.get('__url__', '')}/issues" | 
					
						
							|  |  |  |         if metadata.get("__url__") | 
					
						
							|  |  |  |         else "", | 
					
						
							| 
									
										
										
										
											2024-10-25 18:39:55 +05:30
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2024-12-24 10:18:41 +01:00
										 |  |  |     extras_require={ | 
					
						
							|  |  |  |         "api": read_api_requirements(),  # API requirements as optional | 
					
						
							| 
									
										
										
										
											2025-02-05 02:33:26 +08:00
										 |  |  |         "tools": read_extra_requirements(),  # API requirements as optional | 
					
						
							| 
									
										
										
										
											2024-12-24 10:18:41 +01:00
										 |  |  |     }, | 
					
						
							|  |  |  |     entry_points={ | 
					
						
							|  |  |  |         "console_scripts": [ | 
					
						
							| 
									
										
										
										
											2025-01-10 20:30:58 +01:00
										 |  |  |             "lightrag-server=lightrag.api.lightrag_server:main [api]", | 
					
						
							| 
									
										
										
										
											2025-02-05 02:56:14 +08:00
										 |  |  |             "lightrag-viewer=lightrag.tools.lightrag_visualizer.graph_visualizer:main [tools]", | 
					
						
							| 
									
										
										
										
											2024-12-24 10:18:41 +01:00
										 |  |  |         ], | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2024-10-08 10:38:50 +08:00
										 |  |  | ) |