diff --git a/db_facts/__init__.py b/db_facts/__init__.py index f967fbe..83510b4 100644 --- a/db_facts/__init__.py +++ b/db_facts/__init__.py @@ -1,4 +1,5 @@ __all__ = [ + '__version__', 'db', 'DBFacts', 'UserErrorException' @@ -8,3 +9,4 @@ from .db_facts_types import DBFacts from .runner import Runner # noqa - flake8 false positive from .db_info import db +from .version import __version__ diff --git a/db_facts/version.py b/db_facts/version.py new file mode 100644 index 0000000..d6497a8 --- /dev/null +++ b/db_facts/version.py @@ -0,0 +1 @@ +__version__ = '4.0.0' diff --git a/docs/source/conf.py b/docs/source/conf.py index 27f83a9..e051530 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -13,7 +13,7 @@ import os import sys sys.path.insert(0, os.path.abspath('../../db-facts/')) - +import db_facts # noqa # -- Project information ----------------------------------------------------- @@ -22,7 +22,7 @@ author = 'Vince Broz' # The full version, including alpha/beta/rc tags -release = '4.0.0' +release = db_facts.version.__version__ # -- General configuration --------------------------------------------------- diff --git a/metrics/bigfiles_high_water_mark b/metrics/bigfiles_high_water_mark index 2921a15..446dfcc 100644 --- a/metrics/bigfiles_high_water_mark +++ b/metrics/bigfiles_high_water_mark @@ -1 +1 @@ -360 +369 diff --git a/metrics/coverage_high_water_mark b/metrics/coverage_high_water_mark index 8a1a0f9..6ccb09b 100644 --- a/metrics/coverage_high_water_mark +++ b/metrics/coverage_high_water_mark @@ -1 +1 @@ -97.9400 \ No newline at end of file +97.9500 \ No newline at end of file diff --git a/metrics/mypy_high_water_mark b/metrics/mypy_high_water_mark index 4de54a5..23993e1 100644 --- a/metrics/mypy_high_water_mark +++ b/metrics/mypy_high_water_mark @@ -1 +1 @@ -73.1700 \ No newline at end of file +73.2400 \ No newline at end of file diff --git a/setup.py b/setup.py index d91ae76..7b08849 100644 --- a/setup.py +++ b/setup.py @@ -5,11 +5,20 @@ from distutils.cmd import Command from setuptools import setup, find_packages from setuptools.command.install import install +from typing import Optional import os import sys -VERSION = '4.0.0' +__version__: Optional[str] = None +# Read in and set version variable without the overhead/requirements +# of the rest of the package. +# +# https://milkr.io/kfei/5-common-patterns-to-version-your-Python-package/5 +dir_path = os.path.dirname(os.path.realpath(__file__)) +with open(os.path.join(dir_path, 'db_facts', 'version.py')) as f: + exec(f.read()) + assert __version__ is not None # From https://circleci.com/blog/continuously-deploying-python-packages-to-pypi-with-circleci/ @@ -19,11 +28,11 @@ class VerifyVersionCommand(install): def run(self): tag = os.getenv('CIRCLE_TAG') - tag_formatted_version = f'v{VERSION}' + tag_formatted_version = f'v{__version__}' if tag != tag_formatted_version: info = "Git tag: {0} does not match the version of this app: {1}".format( - tag, VERSION + tag, __version__ ) sys.exit(info) @@ -96,10 +105,10 @@ def initialize_options(self) -> None: long_description = f.read() setup(name='db_facts', - version=VERSION, + version=__version__, # noqa description='Database connection configuration manager', long_description=long_description, - download_url=f'https://github.com/bluelabsio/db-facts/tarball/{VERSION}', + download_url=f'https://github.com/bluelabsio/db-facts/tarball/{__version__}', # noqa author='Vince Broz', author_email='opensource@bluelabs.com', packages=find_packages(),