| 8 | REQUIRED_COLDTYPE = "0.13.7" |
| 9 | |
| 10 | def do_import(): |
| 11 | global coldtype_status, C, ct, cb |
| 12 | |
| 13 | modified_path = False |
| 14 | |
| 15 | inlines = Path(__file__).parent / "inline-packages" |
| 16 | |
| 17 | python_version = f"{sys.version_info.major}.{sys.version_info.minor}" |
| 18 | st2_venv_lib = Path(__file__).parent / f"st2_venv/lib/python{python_version}/site-packages" |
| 19 | if not st2_venv_lib.exists(): |
| 20 | st2_venv_lib = Path(__file__).parent / f"st2_venv/Lib/site-packages" |
| 21 | |
| 22 | if inlines.exists() and "coldtype" not in sys.modules: |
| 23 | modified_path = True |
| 24 | sys.path.insert(0, str(inlines)) |
| 25 | |
| 26 | if st2_venv_lib.exists() and "coldtype" not in sys.modules: |
| 27 | print("attempting st2_venv...") |
| 28 | modified_path = True |
| 29 | print(st2_venv_lib) |
| 30 | sys.path.insert(0, str(st2_venv_lib)) |
| 31 | |
| 32 | def vt(v): |
| 33 | return tuple([int(x.split("a")[0]) for x in v.split(".")]) |
| 34 | |
| 35 | try: |
| 36 | import coldtype as C |
| 37 | import coldtype.text as ct |
| 38 | import coldtype.blender as cb |
| 39 | |
| 40 | if vt(C.__version__) < vt(REQUIRED_COLDTYPE): |
| 41 | C, ct, cb = None, None, None |
| 42 | coldtype_status = 0 |
| 43 | else: |
| 44 | coldtype_status = 1 |
| 45 | |
| 46 | except ImportError as e: |
| 47 | print("COLDTYPE IMPORT ERROR", e) |
| 48 | C, ct, cb = None, None, None |
| 49 | coldtype_status = -1 |
| 50 | |
| 51 | if C: |
| 52 | print("import:COLDTYPE", C.__version__, C.__file__) |
| 53 | else: |
| 54 | print("import:COLDTYPE:fail") |
| 55 | |
| 56 | try: |
| 57 | import AppKit, CoreText |
| 58 | except ImportError: |
| 59 | print("NO APPKIT/CORETEXT") |
| 60 | |
| 61 | #import uharfbuzz as asdf |
| 62 | #print(asdf) |
| 63 | |
| 64 | if modified_path: |
| 65 | sys.path.pop(0) |
| 66 | |
| 67 | |