Skip to content

Commit 53be3d9

Browse files
committed
Move AutoSplit version to pyproject.toml
1 parent a8e0249 commit 53be3d9

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "AutoSplit"
3-
version = "0"
3+
version = "2.3.2"
44
requires-python = ">=3.13"
55
dependencies = [
66
# Dependencies:

scripts/build.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ $arguments = @(
1010
'--windowed',
1111
'--additional-hooks-dir=Pyinstaller/hooks',
1212
'--optimize 2', # Remove asserts and docstrings for smaller build
13+
"--add-data=pyproject.toml$([System.IO.Path]::PathSeparator).",
1314
'--icon=res/icon.ico')
1415
if ($SupportsSplashScreen) {
1516
# https://github.com/pyinstaller/pyinstaller/issues/9022

src/utils.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
import shutil
44
import subprocess # noqa: S404
55
import sys
6+
import tomllib
67
from collections.abc import Callable, Iterable, Sequence
78
from enum import IntEnum
89
from functools import partial
910
from itertools import chain
11+
from pathlib import Path
1012
from platform import version
1113
from threading import Thread
1214
from typing import TYPE_CHECKING, Any, TypedDict, TypeGuard, TypeVar
@@ -39,12 +41,23 @@
3941

4042

4143
if TYPE_CHECKING:
44+
from _typeshed import StrPath
45+
4246
# Source does not exist, keep this under TYPE_CHECKING
4347
from _win32typing import PyCDC # pyright: ignore[reportMissingModuleSource]
4448

4549
T = TypeVar("T")
4650

4751

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+
4861
def find_tesseract_path():
4962
search_path = os.environ.get("PATH", os.defpath)
5063
if sys.platform == "win32":
@@ -328,7 +341,9 @@ def list_processes():
328341
"""The directory of either the AutoSplit executable or AutoSplit.py"""
329342

330343
# 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+
)
334349
GITHUB_REPOSITORY = AUTOSPLIT_GITHUB_REPOSITORY

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)