File python-krr.spec of Package python-krr
#
# spec file for package python-krr
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define skip_python312 1
%define skip_python313 1
%{?sle15_python_module_pythons}
Name: python-krr
Version: 1.25.1
Release: 0
Summary: Prometheus-based Kubernetes Resource Recommendations
License: MIT
URL: https://github.com/robusta-dev/krr
Source: krr-%{version}.tar.gz
Patch1: 0001-pyproject.toml-add-pydantic-settings.patch
Patch2: 0002-robusta_krr-core-models-config.py-import-pydantic_se.patch
Patch3: 0003-robusta_krr-main.py-adapt-field_meta-to-work-with-ne.patch
BuildArch: noarch
BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildRequires: %{python_module base >= 3.9 with %python-base < 3.13}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module poetry-core}
# Add runtime requires as BuildRequires
# to only build if all dependencies are present
# START runtime dependencies
BuildRequires: %{python_module typer >= 0.7.0}
BuildRequires: %{python_module pydantic >= 2.0.0}
BuildRequires: %{python_module kubernetes >= 26.1.0}
BuildRequires: %{python_module prometheus-api-client >= 0.5.3}
BuildRequires: %{python_module numpy >= 1.26.4 with %python-numpy < 1.27.0}
BuildRequires: %{python_module alive-progress >= 3.1.2}
BuildRequires: %{python_module prometrix >= 0.2.1}
BuildRequires: %{python_module slack-sdk >= 3.21.3}
BuildRequires: %{python_module pandas >= 2.2.2}
BuildRequires: %{python_module requests >= 2.32.0}
BuildRequires: %{python_module PyYAML >= 6.0.1}
BuildRequires: %{python_module typing-extensions >= 4.6.0}
BuildRequires: %{python_module idna >= 3.7}
BuildRequires: %{python_module urllib3 >= 1.26.20}
BuildRequires: %{python_module setuptools >= 70.0.0}
BuildRequires: %{python_module zipp >= 3.19.1}
# END runtime dependencies
# START test dependencies
BuildRequires: %{python_module pytest >= 7.2.2}
# END test dependencies
# RUNTIME dependencies
Requires: (python-numpy >= 1.26.4 with python-numpy < 1.27.0)
Requires: (python-urllib3 >= 1.26.20 with python-urllib < 2)
Requires: python-PyYAML >= 6.0.1
Requires: python-alive-progress >= 3.1.2
Requires: python-idna >= 3.7
Requires: python-kubernetes >= 26.1.0
Requires: python-pandas >= 2.2.2
Requires: python-prometheus-api-client >= 0.5.3
Requires: python-prometrix >= 0.2.1
Requires: python-pydantic >= 2.0.0
Requires: python-pydantic-settings >= 2.0.0
Requires: python-requests >= 2.32.0
Requires: python-setuptools >= 70.0.0
Requires: python-slack-sdk >= 3.21.3
Requires: python-typer >= 0.7.0
Requires: python-typing-extensions >= 4.6.0
Requires: python-zipp >= 3.19.1
Requires(post): update-alternatives
Requires(postun):update-alternatives
%python_subpackages
%description
Robusta KRR (Kubernetes Resource Recommender) is a CLI tool for optimizing
resource allocation in Kubernetes clusters. It gathers pod usage data from
Prometheus and recommends requests and limits for CPU and memory. This reduces
costs and improves performance.
%prep
%autosetup -p1 -n krr-%{version}
%build
sed -i '/^version/ s/^.*$/version = "%{version}"/' pyproject.toml
%pyproject_wheel
%install
%pyproject_install
%python_clone -a %{buildroot}%{_bindir}/krr
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
# checks disabled as pydantic in Tumbleweed is way to new for krr
# see https://github.com/robusta-dev/krr/issues/244
%post
%python_install_alternative krr
%postun
%python_uninstall_alternative krr
%files %{python_files}
%doc README.md
%{python_sitelib}/robusta_krr
%{python_sitelib}/robusta_krr-%{version}.dist-info
%python_alternative %{_bindir}/krr
%changelog