diff --git a/cmweather/__init__.py b/cmweather/__init__.py index 992601d..02d6b09 100644 --- a/cmweather/__init__.py +++ b/cmweather/__init__.py @@ -59,12 +59,11 @@ * plasmidis """ -from pkg_resources import DistributionNotFound, get_distribution - +from importlib.metadata import version, PackageNotFoundError from . import cm, cm_colorblind # noqa -# Get the version try: - __version__ = get_distribution(__name__).version -except DistributionNotFound: # pragma: no cover - __version__ = '0.0.0' # pragma: no cover + __version__ = version('cmweather') +except PackageNotFoundError: + # package is not installed + pass diff --git a/docs/source/_static/pst-versions.json b/docs/source/_static/pst-versions.json index 69def11..74b3a4b 100644 --- a/docs/source/_static/pst-versions.json +++ b/docs/source/_static/pst-versions.json @@ -1,7 +1,7 @@ [ { "version": "dev", - "url": "https://cmweather.readthedocs.io/en/" + "url": "https://cmweather.readthedocs.io/en/dev" }, { "version": "latest", diff --git a/docs/source/conf.py b/docs/source/conf.py index b922983..bdf3ef7 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -12,6 +12,7 @@ import datetime import os +import re import sys # If extensions (or modules to document with autodoc) are in another directory, @@ -92,12 +93,19 @@ # built documents. # # The short X.Y version. -version = cmweather.__version__.split('+')[0] -# The full version, including alpha/beta/rc tags. -release = cmweather.__version__ +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +verinfo = cmweather.__version__ +parsed_version = re.search(r'(?P(?P\d+\.\d+)\.?\w*)', verinfo).groupdict() -if '+' in version: +# The short X.Y version. +version = parsed_version['base'] +if '+' in verinfo: version += 'dev' +# The full version, including alpha/beta/rc tags. +release = parsed_version['full'] # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -147,12 +155,12 @@ # further. For a list of options available for each theme, see the # documentation. html_theme_options = { + 'navbar_start': ['navbar-logo', 'version-switcher'], 'switcher': { 'json_url': 'https://raw.githubusercontent.com/mgrover1/cmweather/add-version-switcher/docs/source/_static/pst-versions.json', 'version_match': 'dev' if 'dev' in version else f'v{version}', - } + }, } -print('dev' if 'dev' in version else f'v{version}') # Add any paths that contain custom themes here, relative to this directory. # html_theme_path = [] diff --git a/setup.py b/setup.py index ed63443..1248efb 100644 --- a/setup.py +++ b/setup.py @@ -44,6 +44,5 @@ zip_safe=False, use_scm_version={ 'version_scheme': 'post-release', - 'local_scheme': 'dirty-tag', }, )