from __future__ import annotations
VERBOSE = False

import sys
import platform
import os
import logging
import datetime
import pathlib
import joblib

import scikit_fluorescence.decorators
from scikit_fluorescence.version import __version__


# Take care of typing
try:
    import typing
    # patch typing system for py<3.8 (TypedDict etc. is missing)
    try:
        import typing_extensions
        for key in typing_extensions.__dict__.keys():
            f = typing_extensions.__dict__[key]
            if callable(f):
                typing.__dict__[key] = f
    except ModuleNotFoundError:
        print(
            "WARNING typing_extensions not found",
            file=sys.stderr
        )
except ModuleNotFoundError:
    print(
        "WARNING typing not found",
        file=sys.stderr
    )
    typing = None


home = pathlib.Path().home()
path = home / '.scikit-fluorescence'
if not path.exists():
    os.makedirs(str(path))
session_str = datetime.datetime.now().strftime('session_%H_%M_%d_%m_%Y')
session_log = path / str(session_str + ".log")
logging.basicConfig(
    filename=str(session_log),
    level=logging.DEBUG
)

# Used to cache function results
cachedir = path / "cache"
memory = joblib.Memory(str(cachedir), verbose=0)
