mini-arcade-core 0.4.0__tar.gz → 0.5.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mini-arcade-core
3
- Version: 0.4.0
3
+ Version: 0.5.3
4
4
  Summary: Tiny scene-based game loop core for small arcade games.
5
5
  License: Copyright (c) 2025 Santiago Rincón
6
6
 
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [project]
6
6
  name = "mini-arcade-core"
7
- version = "0.4.0"
7
+ version = "0.5.3"
8
8
  description = "Tiny scene-based game loop core for small arcade games."
9
9
  authors = [
10
10
  { name = "Santiago Rincon", email = "rincores@gmail.com" },
@@ -57,6 +57,8 @@ strict = false
57
57
  disable = [
58
58
  # Justification: Allow classes with few public methods for simplicity.
59
59
  "too-few-public-methods",
60
+ # Justification: f-strings are preferred for logging.
61
+ "logging-fstring-interpolation",
60
62
  # Justification: TODOs are acceptable during development.
61
63
  "fixme",
62
64
  ]
@@ -5,11 +5,16 @@ Provides access to core classes and a convenience function to run a game.
5
5
 
6
6
  from __future__ import annotations
7
7
 
8
+ import logging
9
+ from importlib.metadata import PackageNotFoundError, version
10
+
8
11
  from .backend import Backend, Event, EventType
9
12
  from .entity import Entity, SpriteEntity
10
13
  from .game import Game, GameConfig
11
14
  from .scene import Scene
12
15
 
16
+ logger = logging.getLogger(__name__)
17
+
13
18
 
14
19
  def run_game(initial_scene_cls: type[Scene], config: GameConfig | None = None):
15
20
  """
@@ -34,3 +39,31 @@ __all__ = [
34
39
  "Event",
35
40
  "EventType",
36
41
  ]
42
+
43
+ PACKAGE_NAME = "mini-arcade-core" # or whatever is in your pyproject.toml
44
+
45
+
46
+ def get_version() -> str:
47
+ """
48
+ Return the installed package version.
49
+
50
+ This is a thin helper around importlib.metadata.version so games can do:
51
+
52
+ from mini_arcade_core import get_version
53
+ print(get_version())
54
+
55
+ :return: The version string of the installed package.
56
+ :rtype: str
57
+
58
+ :raises PackageNotFoundError: If the package is not installed.
59
+ """
60
+ try:
61
+ return version(PACKAGE_NAME)
62
+ except PackageNotFoundError: # if running from source / editable
63
+ logger.warning(
64
+ f"Package '{PACKAGE_NAME}' not found. Returning default version '0.0.0'."
65
+ )
66
+ return "0.0.0"
67
+
68
+
69
+ __version__ = get_version()