from .info_event import InfoEvent
from .line_request import LineRequest
from .line_settings import LineSettings
+from .version import __version__
-__version__ = _ext.__version__
+api_version = _ext.api_version
def is_gpiochip_device(path: str) -> bool:
if (!module)
return NULL;
- ret = PyModule_AddStringConstant(module, "__version__",
+ ret = PyModule_AddStringConstant(module, "api_version",
gpiod_version_string());
if (ret) {
Py_DECREF(module);
--- /dev/null
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# SPDX-FileCopyrightText: 2022 Linaro Ltd.
+# SPDX-FileCopyrightTest: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+__version__ = "2.0.0"
if with_tests:
extensions.append(gpiosim_ext)
-# FIXME Find a better way to get the version
-version = None
-try:
- version = environ["GPIOD_VERSION_STR"]
-except KeyError:
- pass
+with open("gpiod/version.py", "r") as fd:
+ exec(fd.read())
setup(
name="gpiod",
packages=find_packages(include=["gpiod"]),
ext_modules=extensions,
- version=version,
+ version=__version__,
)
import gpiod
import os
-import re
import unittest
from . import gpiosim
class VersionString(TestCase):
- def test_version_string(self):
- self.assertTrue(
- re.match(
- "^[0-9][1-9]?\\.[0-9][1-9]?([\\.0-9]?|\\-devel)$", gpiod.__version__
- )
- )
+
+ VERSION_PATTERN = "^[0-9][1-9]?\\.[0-9][1-9]?(\\.[0-9]?|\\-devel)$"
+
+ def test_api_version_string(self):
+ self.assertRegex(gpiod.api_version, VersionString.VERSION_PATTERN)
+
+ def test_module_version(self):
+ self.assertRegex(gpiod.__version__, VersionString.VERSION_PATTERN)