diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c10e3f5..a955393 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,10 @@ Changelog ================================================= +v1.9.1 +------ +* centralize version number to a single place + v1.9.0 ------ * add beam_ellipticity() diff --git a/docs/conf.py b/docs/conf.py index fd19e34..89d545a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,10 +2,23 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # -import os import sys +import os.path import sphinx_rtd_theme +def read(rel_path): + here = os.path.abspath(os.path.dirname(__file__)) + with open(os.path.join(here, rel_path), 'r', encoding='utf-8') as fp: + return fp.read() + +def get_version(rel_path): + for line in read(rel_path).splitlines(): + if line.startswith('__version__'): + delim = '"' if '"' in line else "'" + return line.split(delim)[1] + else: + raise RuntimeError("Unable to find version string.") + sys.path.insert(0, os.path.abspath('.')) sys.path.insert(0, os.path.abspath('..')) @@ -15,9 +28,7 @@ copyright = '2017-22, Scott Prahl' author = 'Scott Prahl' -# The full version, including alpha/beta/rc tags -release = '1.9.0' - +release = get_version("../laserbeamsize/__init__.py") master_doc = 'index' # -- General configuration --------------------------------------------------- diff --git a/docs/sbfit.png b/docs/sbfit.png index 0263ab9..5c3413b 100644 Binary files a/docs/sbfit.png and b/docs/sbfit.png differ diff --git a/laserbeamsize/__init__.py b/laserbeamsize/__init__.py index bb18a23..8728e4c 100644 --- a/laserbeamsize/__init__.py +++ b/laserbeamsize/__init__.py @@ -19,4 +19,4 @@ from .laserbeamsize import * from .m2 import * -__version__ = '1.9.0' +__version__ = '1.9.1' diff --git a/release.txt b/release.txt index 07bbdd5..1179da2 100644 --- a/release.txt +++ b/release.txt @@ -5,10 +5,8 @@ Releasing a new version # check make rcheck -# update the version in three different places! -# setup.cfg docs/conf.py laserbeamsize/__init__.py - - git commit -m 'update version' setup.cfg docs/conf.py +# update the version in __init__.py + git commit -m 'update version' laserbeamsize/__init__.py # update CHANGELOG.rst `git shortlog v1.9.0..HEAD` git commit -m 'update recent changes' CHANGELOG.rst diff --git a/sbfit.png b/sbfit.png index 0263ab9..5c3413b 100644 Binary files a/sbfit.png and b/sbfit.png differ diff --git a/setup.cfg b/setup.cfg index ff8ad2e..fecce65 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,5 @@ [metadata] name = laserbeamsize -version = 1.9.0 author = Scott Prahl author_email = scott.prahl@oit.edu license = MIT diff --git a/setup.py b/setup.py index cb95015..accbf03 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,21 @@ +import os.path from setuptools import setup -# use README.rst as the long description -# make sure to use the syntax that works in both ReST and markdown -from os import path -this_directory = path.abspath(path.dirname(__file__)) -with open(path.join(this_directory, 'README.rst'), encoding='utf-8') as f: - long_description = f.read() +def read(rel_path): + here = os.path.abspath(os.path.dirname(__file__)) + with open(os.path.join(here, rel_path), 'r', encoding='utf-8') as fp: + return fp.read() + +def get_version(rel_path): + for line in read(rel_path).splitlines(): + if line.startswith('__version__'): + delim = '"' if '"' in line else "'" + return line.split(delim)[1] + else: + raise RuntimeError("Unable to find version string.") setup( - long_description=long_description, - long_description_content_type='text/x-rst' + long_description = read('README.rst'), + long_description_content_type = 'text/x-rst', + version = get_version("laserbeamsize/__init__.py") )