This commit is contained in:
Sander Land committed 2020-06-19 13:57:55 +02:00
1 parent 44429b626f
commit 688bed6121
7 files changed
+606 -15

No files matched your search

+16 -11
View File
@@ -27,24 +27,29 @@ def evaluation_class(points_lost: float, eval_thresholds: List[float]):
return i
def check_thread(tb=False): # for checking if draws occur in correct thread
def check_thread(tb=False): # for checking if draws occur in correct thread
import threading
print('build in ', threading.current_thread().ident)
print("build in ", threading.current_thread().ident)
if tb:
import traceback
traceback.print_stack()
PACKAGE_PATH = None
def find_package_resource(path, silent_errors=False):
global PACKAGE_PATH
if path.startswith("katrain"):
parts = path.replace("\\", "/").split("/")
try:
with pkg_resources.path(".".join(parts[:-1]), parts[-1]) as path_obj:
return str(path_obj) # this will clean up if egg etc, but these don't work anyway
except (ModuleNotFoundError, FileNotFoundError, ValueError) as e:
if silent_errors:
return None
print(f"File {path} not found, installation possibly broken", file=sys.stderr)
return f"FILENOTFOUND::{path}"
if PACKAGE_PATH is None:
try:
with pkg_resources.path("katrain", "__init__.py") as p:
PACKAGE_PATH = os.path.split(str(p))[0]
except (ModuleNotFoundError, FileNotFoundError, ValueError) as e:
print(f"Package file {path} not found, installation possibly broken", file=sys.stderr)
return f"FILENOTFOUND/{path}"
return os.path.join(PACKAGE_PATH, path.replace("katrain\\", "katrain/").replace("katrain/", ""))
else:
return os.path.abspath(os.path.expanduser(path)) # absolute path