diff --git a/scopesim/__init__.py b/scopesim/__init__.py index 334da299..9902b487 100644 --- a/scopesim/__init__.py +++ b/scopesim/__init__.py @@ -1,12 +1,23 @@ """Generalised telescope observation simulator.""" +from importlib import metadata + +############################################################################### +# VERSION INFORMATION # +############################################################################### + +try: + __version__ = metadata.version(__package__) +except metadata.PackageNotFoundError: + __version__ = "undetermined" + + ############################################################################### # TURN OFF WARNINGS # ############################################################################### import warnings import yaml -from importlib import metadata from astropy.utils.exceptions import AstropyWarning warnings.simplefilter('ignore', UserWarning) @@ -58,12 +69,3 @@ list_example_data, download_example_data) from .tests.mocks.load_basic_instrument import load_example_optical_train - -############################################################################### -# VERSION INFORMATION # -############################################################################### - -try: - __version__ = metadata.version(__package__) -except metadata.PackageNotFoundError: - __version__ = "undetermined" diff --git a/scopesim/optics/optical_train.py b/scopesim/optics/optical_train.py index 65042803..92add950 100644 --- a/scopesim/optics/optical_train.py +++ b/scopesim/optics/optical_train.py @@ -19,8 +19,7 @@ from ..detector import DetectorArray from ..effects import ExtraFitsKeywords from ..utils import from_currsys, top_level_catch -from ..version import version -from .. import rc +from .. import rc, __version__ class OpticalTrain: @@ -353,7 +352,7 @@ def write_header(self, hdulist): # Primary hdu pheader = hdulist[0].header pheader["DATE"] = datetime.now().isoformat(timespec="seconds") - pheader["ORIGIN"] = "Scopesim " + version + pheader["ORIGIN"] = f"Scopesim {__version__}" pheader["INSTRUME"] = from_currsys("!OBS.instrument") pheader["INSTMODE"] = ", ".join(from_currsys("!OBS.modes")) pheader["TELESCOP"] = from_currsys("!TEL.telescope") diff --git a/scopesim/version.py b/scopesim/version.py deleted file mode 100644 index c3a8644b..00000000 --- a/scopesim/version.py +++ /dev/null @@ -1,5 +0,0 @@ -from importlib import metadata -try: - version = metadata.version(__package__) -except: - version = 0.8