diff --git a/convert-falcon-hf-to-gguf.py b/convert-falcon-hf-to-gguf.py index 99abf078c..271e58972 100755 --- a/convert-falcon-hf-to-gguf.py +++ b/convert-falcon-hf-to-gguf.py @@ -15,9 +15,8 @@ import numpy as np import torch from transformers import AutoTokenizer # type: ignore[import] -# Use local gguf module if available. -if 'NO_LOCAL_GGUF' not in os.environ and Path(__file__).parent.absolute().joinpath('gguf-py', 'gguf', '__init__.py').is_file(): - sys.path.insert(1, str(Path(__file__).parent.absolute().joinpath('gguf-py', 'gguf'))) +if 'NO_LOCAL_GGUF' not in os.environ: + sys.path.insert(1, str(Path(__file__).parent / 'gguf-py' / 'gguf')) import gguf diff --git a/convert-gptneox-hf-to-gguf.py b/convert-gptneox-hf-to-gguf.py index abbddf3fb..b9c8b4607 100755 --- a/convert-gptneox-hf-to-gguf.py +++ b/convert-gptneox-hf-to-gguf.py @@ -15,9 +15,8 @@ import numpy as np import torch from transformers import AutoTokenizer # type: ignore[import] -# Use local gguf module if available. -if 'NO_LOCAL_GGUF' not in os.environ and Path(__file__).parent.absolute().joinpath('gguf-py', 'gguf', '__init__.py').is_file(): - sys.path.insert(1, str(Path(__file__).parent.absolute().joinpath('gguf-py', 'gguf'))) +if 'NO_LOCAL_GGUF' not in os.environ: + sys.path.insert(1, str(Path(__file__).parent / 'gguf-py' / 'gguf')) import gguf # ref: https://github.com/openai/gpt-2/blob/master/src/encoder.py diff --git a/convert-llama-ggmlv3-to-gguf.py b/convert-llama-ggmlv3-to-gguf.py index 43bc3f765..08ba0c490 100755 --- a/convert-llama-ggmlv3-to-gguf.py +++ b/convert-llama-ggmlv3-to-gguf.py @@ -10,9 +10,8 @@ from pathlib import Path import numpy as np import os -# Use local gguf module if available. -if 'NO_LOCAL_GGUF' not in os.environ and Path(__file__).parent.absolute().joinpath('gguf-py', 'gguf', '__init__.py').is_file(): - sys.path.insert(1, str(Path(__file__).parent.absolute().joinpath('gguf-py', 'gguf'))) +if 'NO_LOCAL_GGUF' not in os.environ: + sys.path.insert(1, str(Path(__file__).parent / 'gguf-py' / 'gguf')) import gguf # Note: Does not support GGML_QKK_64 diff --git a/convert.py b/convert.py index 78cbb7b7a..5cc3f6e66 100755 --- a/convert.py +++ b/convert.py @@ -29,9 +29,8 @@ import numpy as np from sentencepiece import SentencePieceProcessor # type: ignore[import] import os -# Use local gguf module if available. -if 'NO_LOCAL_GGUF' not in os.environ and Path(__file__).parent.absolute().joinpath('gguf-py', 'gguf', '__init__.py').is_file(): - sys.path.insert(1, str(Path(__file__).parent.absolute().joinpath('gguf-py', 'gguf'))) +if 'NO_LOCAL_GGUF' not in os.environ: + sys.path.insert(1, str(Path(__file__).parent / 'gguf-py' / 'gguf')) import gguf if TYPE_CHECKING: diff --git a/examples/train-text-from-scratch/convert-train-checkpoint-to-gguf.py b/examples/train-text-from-scratch/convert-train-checkpoint-to-gguf.py index 46b48cb09..a527d6153 100644 --- a/examples/train-text-from-scratch/convert-train-checkpoint-to-gguf.py +++ b/examples/train-text-from-scratch/convert-train-checkpoint-to-gguf.py @@ -8,9 +8,8 @@ import sys import numpy as np from pathlib import Path -# Use local gguf module if available. -if 'NO_LOCAL_GGUF' not in os.environ and Path(__file__).parent.absolute().joinpath('..', '..', 'gguf-py', 'gguf', '__init__.py').is_file(): - sys.path.insert(1, str(Path(__file__).parent.absolute().joinpath('..', '..', 'gguf-py', 'gguf'))) +if 'NO_LOCAL_GGUF' not in os.environ: + sys.path.insert(1, str(Path(__file__).parent / '..' / '..' / 'gguf-py' / 'gguf')) import gguf # gguf constants