2023-05-10 13:38:32 -04:00
|
|
|
from setuptools import setup, find_packages
|
|
|
|
import os
|
2024-02-13 17:44:33 -05:00
|
|
|
import pathlib
|
2023-05-10 13:38:32 -04:00
|
|
|
import platform
|
|
|
|
import shutil
|
|
|
|
|
|
|
|
package_name = "gpt4all"
|
|
|
|
|
|
|
|
# Define the location of your prebuilt C library files
|
2024-01-12 16:13:46 -05:00
|
|
|
SRC_CLIB_DIRECTORY = os.path.join("..", "..", "gpt4all-backend")
|
2023-05-10 14:07:56 -04:00
|
|
|
SRC_CLIB_BUILD_DIRECTORY = os.path.join("..", "..", "gpt4all-backend", "build")
|
2023-05-10 13:38:32 -04:00
|
|
|
|
|
|
|
LIB_NAME = "llmodel"
|
|
|
|
|
|
|
|
DEST_CLIB_DIRECTORY = os.path.join(package_name, f"{LIB_NAME}_DO_NOT_MODIFY")
|
|
|
|
DEST_CLIB_BUILD_DIRECTORY = os.path.join(DEST_CLIB_DIRECTORY, "build")
|
|
|
|
|
|
|
|
system = platform.system()
|
|
|
|
|
|
|
|
def get_c_shared_lib_extension():
|
|
|
|
|
|
|
|
if system == "Darwin":
|
|
|
|
return "dylib"
|
|
|
|
elif system == "Linux":
|
|
|
|
return "so"
|
|
|
|
elif system == "Windows":
|
|
|
|
return "dll"
|
|
|
|
else:
|
|
|
|
raise Exception("Operating System not supported")
|
|
|
|
|
|
|
|
lib_ext = get_c_shared_lib_extension()
|
|
|
|
|
|
|
|
def copy_prebuilt_C_lib(src_dir, dest_dir, dest_build_dir):
|
|
|
|
files_copied = 0
|
|
|
|
|
|
|
|
if not os.path.exists(dest_dir):
|
|
|
|
os.mkdir(dest_dir)
|
|
|
|
os.mkdir(dest_build_dir)
|
|
|
|
|
2023-05-10 15:58:27 -04:00
|
|
|
for dirpath, _, filenames in os.walk(src_dir):
|
|
|
|
for item in filenames:
|
|
|
|
# copy over header files to dest dir
|
|
|
|
s = os.path.join(dirpath, item)
|
|
|
|
if item.endswith(".h"):
|
|
|
|
d = os.path.join(dest_dir, item)
|
|
|
|
shutil.copy2(s, d)
|
|
|
|
files_copied += 1
|
2024-05-15 15:27:50 -04:00
|
|
|
if item.endswith(lib_ext) or item.endswith('.metallib'):
|
2023-05-10 13:38:32 -04:00
|
|
|
s = os.path.join(dirpath, item)
|
2023-05-10 15:58:27 -04:00
|
|
|
d = os.path.join(dest_build_dir, item)
|
|
|
|
shutil.copy2(s, d)
|
|
|
|
files_copied += 1
|
2023-05-10 13:38:32 -04:00
|
|
|
|
|
|
|
return files_copied
|
|
|
|
|
|
|
|
|
|
|
|
# NOTE: You must provide correct path to the prebuilt llmodel C library.
|
|
|
|
# Specifically, the llmodel.h and C shared library are needed.
|
2024-01-12 16:13:46 -05:00
|
|
|
copy_prebuilt_C_lib(SRC_CLIB_DIRECTORY,
|
2023-05-10 13:38:32 -04:00
|
|
|
DEST_CLIB_DIRECTORY,
|
|
|
|
DEST_CLIB_BUILD_DIRECTORY)
|
|
|
|
|
2024-02-13 17:44:33 -05:00
|
|
|
|
|
|
|
def get_long_description():
|
|
|
|
with open(pathlib.Path(__file__).parent / "README.md", encoding="utf-8") as fp:
|
|
|
|
return fp.read()
|
|
|
|
|
|
|
|
|
2023-05-10 13:38:32 -04:00
|
|
|
setup(
|
|
|
|
name=package_name,
|
2024-08-14 13:30:14 -04:00
|
|
|
version="2.8.2",
|
2023-05-10 13:38:32 -04:00
|
|
|
description="Python bindings for GPT4All",
|
2024-02-13 17:44:33 -05:00
|
|
|
long_description=get_long_description(),
|
|
|
|
long_description_content_type="text/markdown",
|
2023-09-01 13:21:41 -04:00
|
|
|
author="Nomic and the Open Source Community",
|
|
|
|
author_email="support@nomic.ai",
|
2024-08-26 16:27:41 -04:00
|
|
|
url="https://www.nomic.ai/gpt4all",
|
2024-02-13 17:44:33 -05:00
|
|
|
project_urls={
|
|
|
|
"Documentation": "https://docs.gpt4all.io/gpt4all_python.html",
|
|
|
|
"Source code": "https://github.com/nomic-ai/gpt4all/tree/main/gpt4all-bindings/python",
|
2024-08-14 16:28:04 -04:00
|
|
|
"Changelog": "https://github.com/nomic-ai/gpt4all/blob/main/gpt4all-bindings/python/CHANGELOG.md",
|
2024-02-13 17:44:33 -05:00
|
|
|
},
|
2023-05-10 13:38:32 -04:00
|
|
|
classifiers = [
|
|
|
|
"Programming Language :: Python :: 3",
|
|
|
|
"License :: OSI Approved :: MIT License",
|
|
|
|
"Operating System :: OS Independent",
|
|
|
|
],
|
|
|
|
python_requires='>=3.8',
|
|
|
|
packages=find_packages(),
|
2024-02-26 13:15:02 -05:00
|
|
|
install_requires=[
|
|
|
|
'requests',
|
|
|
|
'tqdm',
|
|
|
|
'importlib_resources; python_version < "3.9"',
|
2024-03-25 17:30:56 -04:00
|
|
|
'typing-extensions>=4.3.0; python_version >= "3.9" and python_version < "3.11"',
|
2024-02-26 13:15:02 -05:00
|
|
|
],
|
2023-05-10 13:38:32 -04:00
|
|
|
extras_require={
|
2024-05-20 18:06:27 -04:00
|
|
|
'cuda': [
|
2024-08-13 19:11:04 -04:00
|
|
|
'nvidia-cuda-runtime-cu11',
|
|
|
|
'nvidia-cublas-cu11',
|
2024-05-20 18:06:27 -04:00
|
|
|
],
|
|
|
|
'all': [
|
|
|
|
'gpt4all[cuda]; platform_system == "Windows" or platform_system == "Linux"',
|
|
|
|
],
|
2023-05-10 13:38:32 -04:00
|
|
|
'dev': [
|
2024-05-20 18:06:27 -04:00
|
|
|
'gpt4all[all]',
|
2023-05-10 13:38:32 -04:00
|
|
|
'pytest',
|
|
|
|
'twine',
|
2023-05-18 11:21:32 -04:00
|
|
|
'wheel',
|
|
|
|
'setuptools',
|
2023-05-10 13:38:32 -04:00
|
|
|
'mkdocs-material',
|
2024-07-01 13:00:14 -04:00
|
|
|
'mkdocs-material[imaging]',
|
2023-05-10 13:38:32 -04:00
|
|
|
'mkautodoc',
|
|
|
|
'mkdocstrings[python]',
|
2023-06-30 16:02:02 -04:00
|
|
|
'mkdocs-jupyter',
|
|
|
|
'black',
|
2024-03-21 11:33:41 -04:00
|
|
|
'isort',
|
|
|
|
'typing-extensions>=3.10',
|
2023-05-10 13:38:32 -04:00
|
|
|
]
|
|
|
|
},
|
|
|
|
package_data={'llmodel': [os.path.join(DEST_CLIB_DIRECTORY, "*")]},
|
|
|
|
include_package_data=True
|
2023-06-09 16:48:46 -04:00
|
|
|
)
|