From 778264fbababf5457fdc031c538f91968d7cefe6 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Mon, 11 Dec 2023 13:35:56 -0500 Subject: [PATCH] python: don't use importlib as_file for a directory The only reason to use as_file is to support copying a file from a frozen package. We don't currently support this anyway, and as_file isn't supported until Python 3.9, so get rid of it. Fixes #1605 --- gpt4all-bindings/python/gpt4all/pyllmodel.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/gpt4all-bindings/python/gpt4all/pyllmodel.py b/gpt4all-bindings/python/gpt4all/pyllmodel.py index 964e4716..6f58d672 100644 --- a/gpt4all-bindings/python/gpt4all/pyllmodel.py +++ b/gpt4all-bindings/python/gpt4all/pyllmodel.py @@ -1,4 +1,3 @@ -import atexit import ctypes import importlib.resources import logging @@ -8,20 +7,14 @@ import re import subprocess import sys import threading -from contextlib import ExitStack from queue import Queue from typing import Callable, Iterable, List logger: logging.Logger = logging.getLogger(__name__) -file_manager = ExitStack() -atexit.register(file_manager.close) # clean up files on exit - # TODO: provide a config file to make this more robust -MODEL_LIB_PATH = file_manager.enter_context(importlib.resources.as_file( - 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():