diff --git a/setup.py b/setup.py index ff5ac0b..7fe46e4 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,16 @@ #!/usr/bin/env python from setuptools import find_packages, setup + +def get_version(): + with open('stix2/version.py') as f: + for line in f.readlines(): + if line.startswith("__version__"): + version = line.split()[-1].strip('"') + return version + raise AttributeError("Package does not have a __version__") + + install_requires = [ 'pytz', 'six', @@ -11,7 +21,7 @@ install_requires = [ setup( name='stix2', description="Produce and consume STIX 2 JSON content", - version='0.2.0', + version=get_version(), packages=find_packages(), install_requires=install_requires, keywords="stix stix2 json cti cyber threat intelligence", diff --git a/stix2/__init__.py b/stix2/__init__.py index 25e160a..904af9c 100644 --- a/stix2/__init__.py +++ b/stix2/__init__.py @@ -23,6 +23,7 @@ from .sdo import (AttackPattern, Campaign, CourseOfAction, Identity, Indicator, Tool, Vulnerability) from .sro import Relationship, Sighting from .utils import get_dict +from .version import __version__ OBJ_MAP = { 'attack-pattern': AttackPattern, diff --git a/stix2/version.py b/stix2/version.py new file mode 100644 index 0000000..d3ec452 --- /dev/null +++ b/stix2/version.py @@ -0,0 +1 @@ +__version__ = "0.2.0"