From fc02451de125fad140322d0e4f7b4a34ee2a5968 Mon Sep 17 00:00:00 2001
From: Yngve Levinsen <yngve.levinsen@ess.eu>
Date: Fri, 11 Sep 2020 12:49:26 +0200
Subject: [PATCH] automatically using package version at runtime

---
 .gitlab-ci.yml  | 11 -----------
 ess/__init__.py | 10 +++++++++-
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 82786b2..1b661a7 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -22,17 +22,6 @@ examples:
   script:
     - python tests.py -v
 
-verify_tag:
-  stage: test
-  before_script:
-    - *pip_install_default
-  script:
-    - CHECKED_VERSION=`python -c "import ess;print(ess.__version__)"`
-    - echo "${CHECKED_VERSION} - ${CI_COMMIT_TAG}"
-    - if [ "${CI_COMMIT_TAG}" == "${CHECKED_VERSION}" ];then exit 0;else exit 1;fi
-  only:
-    - tags
-
 pages:
   stage: deploy
   script:
diff --git a/ess/__init__.py b/ess/__init__.py
index 7f20938..639646e 100644
--- a/ess/__init__.py
+++ b/ess/__init__.py
@@ -3,6 +3,7 @@ from . import installed
 from . import lib_tw
 from . import fieldmap
 from .nextcloud import nextcloud
+from pkg_resources import get_distribution, DistributionNotFound
 
 __all__ = [
     "fieldmap",
@@ -13,4 +14,11 @@ __all__ = [
     "ttf.py",
     "nextcloud",
 ]
-__version__ = "2.10.4"
+
+__name__ = "ess-python-tools"
+
+try:
+    __version__ = get_distribution(__name__).version
+except DistributionNotFound:
+    # package is not installed
+    pass
-- 
GitLab