diff --git a/docs/conf.py b/docs/conf.py index 0bbc8496..5ae30ba3 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -19,6 +19,7 @@ # import os # import sys # sys.path.insert(0, os.path.abspath('.')) +from importlib.metadata import version # -- General configuration ------------------------------------------------ @@ -31,7 +32,7 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -__version__ = __import__('goodman_pipeline').__version__ +__version__ = version('goodman_pipeline') extensions = ['sphinx.ext.todo', 'sphinx.ext.coverage', diff --git a/goodman_pipeline/__init__.py b/goodman_pipeline/__init__.py index b5efb05f..cb8b1a98 100644 --- a/goodman_pipeline/__init__.py +++ b/goodman_pipeline/__init__.py @@ -1,9 +1,11 @@ from __future__ import absolute_import -from .version import __version__ +from importlib.metadata import version from . import spectroscopy from . import images from . import core -from .core import setup_logging \ No newline at end of file +from .core import setup_logging + +__version__ = version('goodman_pipeline') diff --git a/goodman_pipeline/core/core.py b/goodman_pipeline/core/core.py index c9115669..41b14edf 100644 --- a/goodman_pipeline/core/core.py +++ b/goodman_pipeline/core/core.py @@ -29,13 +29,14 @@ from astropy.stats import sigma_clip from astropy.time import Time from astroscrappy import detect_cosmics +from importlib.metadata import version from matplotlib import pyplot as plt from scipy import signal, interpolate from threading import Timer from . import check_version -__version__ = __import__('goodman_pipeline').__version__ +__version__ = version('goodman_pipeline') log = logging.getLogger(__name__) diff --git a/goodman_pipeline/core/tests/test_check_version.py b/goodman_pipeline/core/tests/test_check_version.py index c3e32971..15a5f756 100644 --- a/goodman_pipeline/core/tests/test_check_version.py +++ b/goodman_pipeline/core/tests/test_check_version.py @@ -3,12 +3,13 @@ import os import unittest - import requests +from importlib.metadata import version + from goodman_pipeline.core import check_version -__version__ = __import__('goodman_pipeline').__version__ +__version__ = version('goodman_pipeline') class TestVersionChecker(unittest.TestCase): diff --git a/goodman_pipeline/images/goodman_ccd.py b/goodman_pipeline/images/goodman_ccd.py index 3072ddca..127b1a74 100755 --- a/goodman_pipeline/images/goodman_ccd.py +++ b/goodman_pipeline/images/goodman_ccd.py @@ -1,9 +1,6 @@ from __future__ import (absolute_import, division, print_function, unicode_literals) -from .data_classifier import DataClassifier -from .night_organizer import NightOrganizer -from .image_processor import ImageProcessor import os import sys @@ -13,6 +10,12 @@ import logging import matplotlib +from importlib.metadata import version + +from .data_classifier import DataClassifier +from .night_organizer import NightOrganizer +from .image_processor import ImageProcessor + log = logging.getLogger(__name__) try: @@ -20,7 +23,7 @@ except ImportError as error: log.warning(error) -__version__ = __import__('goodman_pipeline').__version__ +__version__ = version('goodman_pipeline') def get_args(arguments=None): diff --git a/goodman_pipeline/spectroscopy/redspec.py b/goodman_pipeline/spectroscopy/redspec.py index 3afeaf6e..a400fcc8 100755 --- a/goodman_pipeline/spectroscopy/redspec.py +++ b/goodman_pipeline/spectroscopy/redspec.py @@ -14,6 +14,17 @@ from __future__ import (absolute_import, division, print_function, unicode_literals) +import sys +import os +import argparse +import astropy.units as u +import logging +from ccdproc import CCDData + +import matplotlib.pyplot as plt +import warnings +from importlib.metadata import version + from .wavelength import WavelengthCalibration from ..core import (classify_spectroscopic_data, search_comp_group, @@ -28,21 +39,11 @@ NoTargetException, ReferenceData) -import sys -import os -import argparse -import astropy.units as u -import logging -from ccdproc import CCDData - -import matplotlib.pyplot as plt -import warnings - SHOW_PLOTS = True warnings.filterwarnings('ignore') -__version__ = __import__('goodman_pipeline').__version__ +__version__ = version('goodman_pipeline') def get_args(arguments=None):