diff --git a/fms_mo/__init__.py b/fms_mo/__init__.py index 64d21082..a49bd8d7 100644 --- a/fms_mo/__init__.py +++ b/fms_mo/__init__.py @@ -13,17 +13,7 @@ # limitations under the License. """FMS Model Optimizer init. Import most commonly used functions and classes here.""" -# Standard -from importlib.metadata import PackageNotFoundError, version -import logging - # Local from fms_mo.prep import qmodel_prep from fms_mo.utils.qconfig_utils import qconfig_init - -VERSION_FALLBACK = "0.0.0" - -try: - __version__ = version("fms_mo") -except PackageNotFoundError: - __version__ = VERSION_FALLBACK +from fms_mo.version import __version__, __version_tuple__ diff --git a/fms_mo/version.py b/fms_mo/version.py new file mode 100644 index 00000000..a87fffa0 --- /dev/null +++ b/fms_mo/version.py @@ -0,0 +1,29 @@ +# Copyright The FMS Model Optimizer Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""FMS Model Optimizer version""" + +try: + # Local + from ._version import ( # pylint: disable=unused-import + __version__, + __version_tuple__, + ) +except ImportError as e: + # Standard + import warnings + + warnings.warn(f"Failed to read commit hash:\n{e}", RuntimeWarning, stacklevel=2) + + __version__ = "dev" + __version_tuple__ = (0, 0, __version__) diff --git a/pyproject.toml b/pyproject.toml index 6df9523a..fe5f086e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] build-backend = "setuptools.build_meta" -requires = ["setuptools>=60", "setuptools-scm>=8.0"] +requires = ["setuptools>=64", "setuptools-scm>=8.0"] [project] name = "fms-model-optimizer" @@ -56,9 +56,15 @@ source = "https://github.com/foundation-model-stack/fms-model-optimizer" issues = "https://github.com/foundation-model-stack/fms-model-optimizer/issues" [tool.setuptools_scm] +# Version files are optional, this just marginally speeds up version inspection +# at runtime version_file = "fms_mo/_version.py" -# do not include +gREV local version, required for Test PyPI upload +# Do not include +gREV local version, required for Test PyPI upload +# Version strings are formatted as `{version}+{local}`, e.g. "0.1.dev1+gb1a7032" +# Local versioning is incompatible with pypi, so we disable it by default. local_scheme = "no-local-version" +# For more version configuration, see +# https://setuptools-scm.readthedocs.io/en/latest/config/ [tool.setuptools.packages.find] where = [""]