diff options
Diffstat (limited to 'ouroboros/dev.py')
| -rw-r--r-- | ouroboros/dev.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ouroboros/dev.py b/ouroboros/dev.py index a2b58cf..d36a3ef 100644 --- a/ouroboros/dev.py +++ b/ouroboros/dev.py @@ -27,6 +27,30 @@ from typing import Optional from _ouroboros_dev_cffi import ffi, lib from ouroboros.qos import * + +def _check_ouroboros_version(): + ouro_major = lib.OUROBOROS_VERSION_MAJOR + ouro_minor = lib.OUROBOROS_VERSION_MINOR + try: + from importlib.metadata import version, PackageNotFoundError + try: + pyouro_parts = version('PyOuroboros').split('.') + except PackageNotFoundError: + return # running from source, skip check + if ouro_major != int(pyouro_parts[0]) or \ + ouro_minor != int(pyouro_parts[1]): + raise RuntimeError( + f"Ouroboros version mismatch: library is " + f"{ouro_major}.{ouro_minor}, " + f"pyouroboros is " + f"{pyouro_parts[0]}.{pyouro_parts[1]}" + ) + except ImportError: + pass # Python < 3.8 + + +_check_ouroboros_version() + # Some constants MILLION = 1000 * 1000 BILLION = 1000 * 1000 * 1000 |
