From 81594fdd2577f2bd08d637c51fef6ba1b21725e5 Mon Sep 17 00:00:00 2001 From: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com> Date: Mon, 9 Jun 2025 21:52:37 -0700 Subject: [PATCH 1/4] Fix versioning Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com> --- fms_mo/__init__.py | 12 +----------- fms_mo/version.py | 26 ++++++++++++++++++++++++++ pyproject.toml | 10 ++++++++-- 3 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 fms_mo/version.py 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..af169e31 --- /dev/null +++ b/fms_mo/version.py @@ -0,0 +1,26 @@ +# 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: + from ._version import __version__, __version_tuple__ +except Exception as e: + import warnings + + warnings.warn(f"Failed to read commit hash:\n{e}", + RuntimeWarning, + stacklevel=2) + + __version__ = "dev" + __version_tuple__ = (0, 0, __version__) \ No newline at end of file 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 = [""] From 521dc9750058c063e2e51aa7e81a9b939e3df400 Mon Sep 17 00:00:00 2001 From: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com> Date: Mon, 9 Jun 2025 21:53:03 -0700 Subject: [PATCH 2/4] fmt Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com> --- fms_mo/version.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fms_mo/version.py b/fms_mo/version.py index af169e31..ce816361 100644 --- a/fms_mo/version.py +++ b/fms_mo/version.py @@ -14,13 +14,13 @@ """FMS Model Optimizer version""" try: + # Local from ._version import __version__, __version_tuple__ except Exception as e: + # Standard import warnings - warnings.warn(f"Failed to read commit hash:\n{e}", - RuntimeWarning, - stacklevel=2) + warnings.warn(f"Failed to read commit hash:\n{e}", RuntimeWarning, stacklevel=2) __version__ = "dev" - __version_tuple__ = (0, 0, __version__) \ No newline at end of file + __version_tuple__ = (0, 0, __version__) From 1b240cb5d93ce1981ae12d486328430f4120f4c3 Mon Sep 17 00:00:00 2001 From: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com> Date: Mon, 9 Jun 2025 21:54:34 -0700 Subject: [PATCH 3/4] Fix lint Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com> --- fms_mo/version.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fms_mo/version.py b/fms_mo/version.py index ce816361..80081b34 100644 --- a/fms_mo/version.py +++ b/fms_mo/version.py @@ -15,8 +15,8 @@ try: # Local - from ._version import __version__, __version_tuple__ -except Exception as e: + from ._version import __version__ +except ImportError as e: # Standard import warnings From 92a76a30ab300ace9576778ff0393015b980cc23 Mon Sep 17 00:00:00 2001 From: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com> Date: Tue, 10 Jun 2025 07:48:32 -0700 Subject: [PATCH 4/4] Fix missing import Signed-off-by: Thara Palanivel <130496890+tharapalanivel@users.noreply.github.com> --- fms_mo/version.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fms_mo/version.py b/fms_mo/version.py index 80081b34..a87fffa0 100644 --- a/fms_mo/version.py +++ b/fms_mo/version.py @@ -15,7 +15,10 @@ try: # Local - from ._version import __version__ + from ._version import ( # pylint: disable=unused-import + __version__, + __version_tuple__, + ) except ImportError as e: # Standard import warnings