Skip to content

Commit

Permalink
python: actually fix python 3.8 compatibility (nomic-ai#1973)
Browse files Browse the repository at this point in the history
importlib.resources.files also didn't exist until python 3.9.

Fixes nomic-ai#1972

Signed-off-by: Jared Van Bortel <[email protected]>
  • Loading branch information
cebtenzzre authored Feb 26, 2024
1 parent a59645c commit 4a16a92
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions gpt4all-bindings/python/gpt4all/_pyllmodel.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import ctypes
import importlib.resources
import logging
import os
import platform
Expand All @@ -13,11 +12,16 @@
from queue import Queue
from typing import Callable, Iterable, List

if sys.version_info >= (3, 9):
import importlib.resources as importlib_resources
else:
import importlib_resources

logger: logging.Logger = logging.getLogger(__name__)


# TODO: provide a config file to make this more robust
MODEL_LIB_PATH = importlib.resources.files("gpt4all") / "llmodel_DO_NOT_MODIFY" / "build"
MODEL_LIB_PATH = importlib_resources.files("gpt4all") / "llmodel_DO_NOT_MODIFY" / "build"


def load_llmodel_library():
Expand Down
6 changes: 5 additions & 1 deletion gpt4all-bindings/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ def get_long_description():
],
python_requires='>=3.8',
packages=find_packages(),
install_requires=['requests', 'tqdm'],
install_requires=[
'requests',
'tqdm',
'importlib_resources; python_version < "3.9"',
],
extras_require={
'dev': [
'pytest',
Expand Down

0 comments on commit 4a16a92

Please sign in to comment.