Skip to content

Commit

Permalink
feat: programmatic access to library's version (#417)
Browse files Browse the repository at this point in the history
adds `cyclonedx.__version__`

Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
  • Loading branch information
jkowalleck authored Aug 27, 2023
1 parent 14c501c commit 3585ea9
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 31 deletions.
4 changes: 4 additions & 0 deletions cyclonedx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@
"""
Python library for generating and representing CycloneDX software bill-of-materials.
"""

# !! version is managed by semantic_release
# do not use typing here, or else `semantic_release` might have issues finding the variable
__version__ = "4.1.0-alpha.1"
11 changes: 1 addition & 10 deletions cyclonedx/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import hashlib
import re
import sys
import warnings
from datetime import datetime, timezone
from enum import Enum
Expand All @@ -26,6 +25,7 @@
import serializable
from sortedcontainers import SortedSet

from .. import __version__ as __ThisToolVersion
from ..exception.model import (
InvalidLocaleTypeException,
InvalidUriException,
Expand Down Expand Up @@ -1394,15 +1394,6 @@ def __repr__(self) -> str:
return f'<Copyright text={self.text}>'


if sys.version_info >= (3, 8):
from importlib.metadata import version as meta_version
else:
from importlib_metadata import version as meta_version

try:
__ThisToolVersion: Optional[str] = str(meta_version('cyclonedx-python-lib')) # type: ignore[no-untyped-call]
except Exception:
__ThisToolVersion = None
ThisTool = Tool(vendor='CycloneDX', name='cyclonedx-python-lib', version=__ThisToolVersion or 'UNKNOWN')
ThisTool.external_references.update([
ExternalReference(
Expand Down
1 change: 0 additions & 1 deletion deps.lowest.r
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@

packageurl-python == 0.11.1
py-serializable == 0.11.1
importlib-metadata == 3.4.0 # ; python_version < '3.8'

# file name is a untypical one, so dependabot does not bump this file
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
import pkg_resources

# -- Project information -----------------------------------------------------

Expand All @@ -22,7 +21,8 @@
author = 'Paul Horton, Jan Kowalleck, Steve Springett, Patrick Dwyer'

# The full version, including alpha/beta/rc tags
release = pkg_resources.get_distribution("cyclonedx-python-lib").version
# !! version is managed by semantic_release
release = '4.1.0-alpha.1'

# -- General configuration ---------------------------------------------------

Expand Down
49 changes: 44 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3585ea9

Please sign in to comment.