From 00afa181748261a2f026e46c1c634ac1f0155e99 Mon Sep 17 00:00:00 2001
From: Anton Tetov <anton@tetov.se>
Date: Thu, 7 Apr 2022 16:52:29 +0200
Subject: [PATCH] ci and versioning

---
 .gitlab-ci.yml          | 1 +
 pyproject.toml          | 5 +++--
 tests/test_ur_py_ctl.py | 8 +++++++-
 ur_py_ctl/__init__.py   | 7 ++++++-
 4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 007582e..ea8f2bf 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -26,6 +26,7 @@ stages:
 .install-deps-template: &install-deps
   <<: *executor
   before_script:
+    - sudo apt update && sudo apt install make
     - pip install poetry
     - poetry --version
     - poetry config virtualenvs.in-project true
diff --git a/pyproject.toml b/pyproject.toml
index 18858ae..dfa5cc8 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,13 +4,14 @@ build-backend = "poetry.core.masonry.api"
 
 [tool.poetry]
 name = "ur_py_ctl"
-version = "0.1.0"
+version = "0.1.1"
 description = "Python wrapper around URScript (for Universal Robotics robots)."
 authors = ["Anton Tetov <anton.johansson@control.lth.se>"]
 repository = "https://gitlab.control.lth.se/robotlab/ur_py_ctl"
 
 [tool.poetry.dependencies]
-python = ">=3.9,<3.12"
+python = ">=3.9,<3.11"
+importlib_metadata = {version = "^1.0", python = "<3.8"}
 
 [tool.poetry.dev-dependencies]
 flake8 = "^4.0.1"
diff --git a/tests/test_ur_py_ctl.py b/tests/test_ur_py_ctl.py
index a1e9b9a..92ca827 100644
--- a/tests/test_ur_py_ctl.py
+++ b/tests/test_ur_py_ctl.py
@@ -1,5 +1,11 @@
+import re
+
 from ur_py_ctl import __version__
 
 
 def test_version():
-    assert __version__ == "0.1.0"
+    assert __version__
+
+
+def test_version_semver():
+    assert re.match(r"(\d+\.)(\d+\.)(\d+(-[\w\.]+)?)", __version__)
diff --git a/ur_py_ctl/__init__.py b/ur_py_ctl/__init__.py
index 1ca033b..4e78504 100644
--- a/ur_py_ctl/__init__.py
+++ b/ur_py_ctl/__init__.py
@@ -1,6 +1,11 @@
 import pathlib
 
-__version__ = "0.1.0"
+try:
+    import importlib.metadata as importlib_metadata
+except ModuleNotFoundError:
+    import importlib_metadata
+
+__version__ = importlib_metadata.version(__name__)
 
 HERE = pathlib.Path(__file__).parent
 REPO_DIR = HERE.parent
-- 
GitLab