diff options
| author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2026-03-07 22:46:56 +0100 |
|---|---|---|
| committer | Dimitri Staessens <dimitri@ouroboros.rocks> | 2026-03-08 14:24:30 +0100 |
| commit | 7d043001b956fb80116cf8eedcca1d5aaf2edbd4 (patch) | |
| tree | d2f925b1f3085cabd0256949a454d15075a8dde8 /ouroboros | |
| parent | 7a4c37e8b673328dda59cec11ab9dce66c22a312 (diff) | |
| download | pyouroboros-7d043001b956fb80116cf8eedcca1d5aaf2edbd4.tar.gz pyouroboros-7d043001b956fb80116cf8eedcca1d5aaf2edbd4.zip | |
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.
Diffstat (limited to 'ouroboros')
| -rw-r--r-- | ouroboros/__init__.py | 21 | ||||
| -rw-r--r-- | ouroboros/dev.py | 24 | ||||
| -rw-r--r-- | ouroboros/irm.py | 24 |
3 files changed, 69 insertions, 0 deletions
diff --git a/ouroboros/__init__.py b/ouroboros/__init__.py new file mode 100644 index 0000000..6034f7d --- /dev/null +++ b/ouroboros/__init__.py @@ -0,0 +1,21 @@ +# +# Ouroboros - Copyright (C) 2016 - 2026 +# +# Python API for Ouroboros +# +# Dimitri Staessens <dimitri@ouroboros.rocks> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# version 2.1 as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., http://www.fsf.org/about/contact/. +# + 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 diff --git a/ouroboros/irm.py b/ouroboros/irm.py index 1e4fc2e..5c23aaa 100644 --- a/ouroboros/irm.py +++ b/ouroboros/irm.py @@ -26,6 +26,30 @@ from _ouroboros_irm_cffi import ffi, lib from ouroboros.qos import QoSSpec +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() + + # Intentionally duplicated: irm uses a separate FFI (ouroboros-irm). def _qos_to_qosspec(qos: QoSSpec): if qos is None: |
