File nvchecker.spec of Package nvchecker

#
# spec file for package nvchecker
#
# Copyright (c) 2021 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 test 0
%if %{test}
%bcond_without test
%else
%bcond_with test
%endif

%{?sle15_python_module_pythons}
Name:           nvchecker
Version:        2.12
Release:        0
Summary:        New version checker for software releases
License:        MIT
Group:          Productivity/Networking/Diagnostic
URL:            https://github.com/lilydjwg/nvchecker
Source0:        https://github.com/lilydjwg/nvchecker/archive/v%{version}/%{name}-%{version}.tar.gz
BuildRequires:  %{python_module base >= 3.7}
BuildRequires:  %{python_module setuptools if %python-base < 3.8}
BuildRequires:  python-rpm-macros
BuildRequires:  %{python_module appdirs}
BuildRequires:  %{python_module packaging}
BuildRequires:  %{python_module pycurl}
BuildRequires:  %{python_module setuptools}
BuildRequires:  %{python_module structlog}
BuildRequires:  %{python_module toml}
BuildRequires:  %{python_module tomli if %python-base < 3.11}
BuildRequires:  %{python_module tornado6}
BuildRequires:  %{python_module typing_extensions}
BuildRequires:  %{python_module pip}
BuildRequires:  %{python_module wheel}
Requires:       python-appdirs
Requires:       python-packaging
Requires:       python-pycurl
Requires:       python-structlog
Requires:       python-toml
Requires:       (python-tomli if python-base < 3.11)
Requires:       python-tornado6
Requires:       python-typing_extensions
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildArch:      noarch
%if %{with test}
BuildRequires:  python-aiohttp
BuildRequires:  python-flaky
BuildRequires:  python-pytest
BuildRequires:  python-pytest-asyncio
BuildRequires:  python-pytest-httpbin
BuildRequires:  python-wheel
%endif
%python_subpackages

%description
nvchecker (short for new version checker) is for checking if a new version of some software has been released.

%prep
%setup -q
sed -i -e 's|#!\/usr\/bin\/env python3||g' nvchecker/*main*.py
find scripts -type f -exec sed -i -e 's|#!\/usr\/bin\/env python3|#!\/usr\/bin\/python3|g' {} \;

%build
%pyproject_wheel

%install
%pyproject_install
%python_clone -a %{buildroot}%{_bindir}/nvchecker
%python_clone -a %{buildroot}%{_bindir}/nvcmp
%python_clone -a %{buildroot}%{_bindir}/nvtake
%python_clone -a %{buildroot}%{_bindir}/nvchecker-ini2toml
%python_clone -a %{buildroot}%{_bindir}/nvchecker-notify
# Not need
##rm -rf %%{buildroot}%%{python_sitelib}/nvchecker_source

%{python_expand rm -rf %{buildroot}%{$python_sitelib}/nvchecker_source}

%if %{with test}
%check
%python_exec setup.py test
%endif

%post
%python_install_alternative nvchecker
%python_install_alternative nvcmp
%python_install_alternative nvtake
%python_install_alternative nvchecker-ini2toml
%python_install_alternative nvchecker-notify

%postun
%python_uninstall_alternative nvchecker
%python_uninstall_alternative nvcmp
%python_uninstall_alternative nvtake
%python_uninstall_alternative nvchecker-ini2toml
%python_uninstall_alternative nvchecker-notify

%files %{python_files}
%license LICENSE
%doc README.rst sample_config.toml scripts
%python_alternative %{_bindir}/nvchecker
%python_alternative %{_bindir}/nvcmp
%python_alternative %{_bindir}/nvtake
%python_alternative %{_bindir}/nvchecker-ini2toml
%python_alternative %{_bindir}/nvchecker-notify
%{python_sitelib}/nvchecker
%dir %{python_sitelib}/nvchecker-%{version}.dist-info
%{python_sitelib}/nvchecker-%{version}.dist-info/*

%changelog
openSUSE Build Service is sponsored by