From 7d043001b956fb80116cf8eedcca1d5aaf2edbd4 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sat, 7 Mar 2026 22:46:56 +0100 Subject: build: Use git tags for versioning Replace setup.py metadata with pyproject.toml and derive version from git tags with setuptools-scm. Adds git archive support for setuptools-scm version detection. --- ouroboros/dev.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'ouroboros/dev.py') 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 -- cgit v1.2.3