Skip to content

Commit

Permalink
New config option mpf: min_mpf_version
Browse files Browse the repository at this point in the history
  • Loading branch information
avanwinkle committed Jul 19, 2024
1 parent 8df70d9 commit 9079562
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions mpf/config_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,7 @@ mpf:
core_modules: ignore
config_players: ignore
device_modules: ignore
min_mpf_version: single|str|None
plugins: ignore
platforms: ignore
paths: ignore
Expand Down
11 changes: 11 additions & 0 deletions mpf/core/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import threading
from typing import Any, Callable, Dict, List, Set, Optional

from packaging import version
from pkg_resources import iter_entry_points

from mpf._version import __version__
Expand Down Expand Up @@ -368,6 +369,16 @@ def _validate_config(self) -> None:
self.validate_machine_config_section('machine')
self.validate_machine_config_section('game')
self.validate_machine_config_section('mpf')
self._validate_version()

def _validate_version(self):
if not self.config['mpf']['min_mpf_version']:
return
min_version = version.parse(self.config['mpf']['min_mpf_version'])
mpf_version = version.parse(__version__)
if mpf_version < min_version:
raise AssertionError(f'MPF version mismatch. MPF version {mpf_version} found but game config '
f'requires at least {min_version} ')

def validate_machine_config_section(self, section: str) -> None:
"""Validate a config section."""
Expand Down

0 comments on commit 9079562

Please sign in to comment.