diff --git a/CveXplore/VERSION b/CveXplore/VERSION deleted file mode 100644 index 6b8dfd23..00000000 --- a/CveXplore/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.3.26 \ No newline at end of file diff --git a/CveXplore/__init__.py b/CveXplore/__init__.py index 03b2ec5d..8c74e62f 100644 --- a/CveXplore/__init__.py +++ b/CveXplore/__init__.py @@ -1,8 +1 @@ from CveXplore.main import CveXplore - -try: - from version import _version - - _version() -except ModuleNotFoundError: - pass diff --git a/CveXplore/main.py b/CveXplore/main.py index 4f5eb300..9abf8f29 100644 --- a/CveXplore/main.py +++ b/CveXplore/main.py @@ -3,6 +3,8 @@ ==== """ +VERSION = __version__ = "0.3.27" + import os import shutil @@ -51,15 +53,6 @@ from CveXplore.objects.cvexplore_object import CveXploreObject -try: - from version import VERSION -except ModuleNotFoundError: - _PKG_DIR = os.path.dirname(__file__) - version_file = os.path.join(_PKG_DIR, "VERSION") - with open(version_file, "r") as fdsec: - VERSION = fdsec.read() - - class CveXplore(object): """ Main class for CveXplore package diff --git a/setup.py b/setup.py index 8510aa29..33bcb83e 100644 --- a/setup.py +++ b/setup.py @@ -3,13 +3,7 @@ from setuptools import setup, find_packages -try: - from version import VERSION -except ModuleNotFoundError: - _PKG_DIR = os.path.dirname(__file__) - version_file = os.path.join(_PKG_DIR, "CveXplore", "VERSION") - with open(version_file, "r") as fdsec: - VERSION = fdsec.read() +from CveXplore.main import VERSION # The directory containing this file HERE = os.path.abspath(os.path.dirname(__file__)) @@ -113,7 +107,6 @@ def extras_require(): package_data={ "CveXplore": [ "LICENSE", - "VERSION", ".schema_version", "common/.sources.ini", "common/.env_example", diff --git a/version.py b/version.py deleted file mode 100644 index fc251d3c..00000000 --- a/version.py +++ /dev/null @@ -1,86 +0,0 @@ -import os -import re -import subprocess - -_PKG_DIR = os.path.dirname(__file__) - - -def _version_from_git_describe(): - """ - - Read the version from ``git describe``. It returns the latest tag with an - optional suffix if the current directory is not exactly on the tag. - - Example:: - - $ git describe --always - v2.3.2-346-g164a52c075c8 - - The tag prefix (``v``) and the git commit sha1 (``-g164a52c075c8``) are - removed if present. - - If the current directory is not exactly on the tag, a ``.devN`` suffix is - appended where N is the number of commits made after the last tag. - - Example:: - - '>>> _version_from_git_describe()' - '2.3.2.dev346' - - """ - if not os.path.isdir(os.path.join(_PKG_DIR, ".git")): # noqa: E501 - raise ValueError("not in git repo") - - process = subprocess.Popen( - ["git", "describe", "--always"], - cwd=_PKG_DIR, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - ) - - out, err = process.communicate() - - if process.returncode == 0: - tag = out.decode().strip() - match = re.match("^v?(.+?)-(\\d+)-g[a-f0-9]+$", tag) - if match: - # remove the 'v' prefix and add a '.devN' suffix - return "%s.dev%s" % (match.group(1), match.group(2)) - else: - # just remove the 'v' prefix - return re.sub("^v", "", tag) - else: - raise subprocess.CalledProcessError(process.returncode, err) - - -def _version(): - version_file = os.path.join(_PKG_DIR, "CveXplore/VERSION") - try: - tag = _version_from_git_describe() - # successfully read the tag from git, write it in VERSION for - # installation and/or archive generation. - with open(version_file, "w") as fdesc: - fdesc.write(tag) - return tag - except Exception: - # failed to read the tag from git, try to read it from a VERSION file - try: - with open(version_file, "r") as fdsec: - tag = fdsec.read() - return tag - except Exception: - # Rely on git archive "export-subst" git attribute. - # See 'man gitattributes' for more details. - git_archive_id = "$Format:%h %d$" - sha1 = git_archive_id.strip().split()[0] - match = re.search("tag:(\\S+)", git_archive_id) - if match: - return "git-archive.dev" + match.group(1) - elif sha1: - return "git-archive.dev" + sha1 - else: - return "unknown.version" - - -VERSION = __version__ = _version() -VERSION_MAIN = re.search(r"[0-9.]+", VERSION).group()