From 5946ff85399d71d0166da66157c449bd8f1fb625 Mon Sep 17 00:00:00 2001 From: Tom Gillespie Date: Mon, 24 Sep 2018 01:30:53 -0700 Subject: [PATCH] core moved git imports inside Ont and Source The ultimate solution here is to move the Source/Ont core classes into their own file. However, until then this will allow systems without git to import other classes. --- pyontutils/core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyontutils/core.py b/pyontutils/core.py index d5bf606e..a681376c 100644 --- a/pyontutils/core.py +++ b/pyontutils/core.py @@ -7,7 +7,6 @@ from pathlib import Path from collections import namedtuple from inspect import getsourcefile -from git import Repo from rdflib.extras import infixowl from joblib import Parallel, delayed import ontquery @@ -672,6 +671,7 @@ class Source(tuple): artifact = None def __new__(cls): + from git import Repo if not hasattr(cls, '_data'): if hasattr(cls, 'runonce'): # must come first since it can modify how cls.source is defined cls.runonce() @@ -876,6 +876,7 @@ def __init__(self, *args, **kwargs): if hasattr(self, '_repo') and not self._repo: commit = 'FAKE-COMMIT' else: + from git import Repo repo = Repo(working_dir.as_posix()) commit = next(repo.iter_commits()).hexsha