|
3 | 3 | import shutil
|
4 | 4 | import subprocess # noqa: S404
|
5 | 5 | import sys
|
| 6 | +import tomllib |
6 | 7 | from collections.abc import Callable, Iterable, Sequence
|
7 | 8 | from enum import IntEnum
|
8 | 9 | from functools import partial
|
9 | 10 | from itertools import chain
|
| 11 | +from pathlib import Path |
10 | 12 | from platform import version
|
11 | 13 | from threading import Thread
|
12 | 14 | from typing import TYPE_CHECKING, Any, TypedDict, TypeGuard, TypeVar
|
|
39 | 41 |
|
40 | 42 |
|
41 | 43 | if TYPE_CHECKING:
|
| 44 | + from _typeshed import StrPath |
| 45 | + |
42 | 46 | # Source does not exist, keep this under TYPE_CHECKING
|
43 | 47 | from _win32typing import PyCDC # pyright: ignore[reportMissingModuleSource]
|
44 | 48 |
|
45 | 49 | T = TypeVar("T")
|
46 | 50 |
|
47 | 51 |
|
| 52 | +def resource_path(relative_path: "StrPath"): |
| 53 | + """ |
| 54 | + Get absolute path to resource, from the root of the repository. |
| 55 | + Works both frozen and unfrozen. |
| 56 | + """ |
| 57 | + base_path = getattr(sys, "_MEIPASS", Path(__file__).parent.parent) |
| 58 | + return os.path.join(base_path, relative_path) |
| 59 | + |
| 60 | + |
48 | 61 | def find_tesseract_path():
|
49 | 62 | search_path = os.environ.get("PATH", os.defpath)
|
50 | 63 | if sys.platform == "win32":
|
@@ -328,7 +341,9 @@ def list_processes():
|
328 | 341 | """The directory of either the AutoSplit executable or AutoSplit.py"""
|
329 | 342 |
|
330 | 343 | # Shared strings
|
331 |
| -# Check `excludeBuildNumber` during workflow dispatch build generate a clean version number |
332 |
| -AUTOSPLIT_VERSION = "2.3.2" + (f"-{AUTOSPLIT_BUILD_NUMBER}" if AUTOSPLIT_BUILD_NUMBER else "") |
333 |
| -"""AutoSplit Version number""" |
| 344 | +with open(resource_path("pyproject.toml"), mode="rb") as pyproject: |
| 345 | + # Check `excludeBuildNumber` during workflow dispatch build generate a clean version number |
| 346 | + AUTOSPLIT_VERSION: str = tomllib.load(pyproject)["project"]["version"] + ( |
| 347 | + f"-{AUTOSPLIT_BUILD_NUMBER}" if AUTOSPLIT_BUILD_NUMBER else "" |
| 348 | + ) |
334 | 349 | GITHUB_REPOSITORY = AUTOSPLIT_GITHUB_REPOSITORY
|
0 commit comments