File python-kiwi_boxed_plugin.spec of Package python-kiwi_boxed_plugin

#
# spec file for package kiwi_boxed_plugin
#
# Copyright (c) 2020 SUSE Software Solutions Germany GmbH, Nuernberg, Germany.
#
# 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://github.com/OSInside/kiwi-boxed-plugin/issues
#

# If they aren't provided by a system installed macro, define them
%{!?_defaultdocdir: %global _defaultdocdir %{_datadir}/doc}

%if 0%{?suse_version} && 0%{?suse_version} < 1600
%global __python3 /usr/bin/python3.11
%global python3_pkgversion 311
%else
%{!?__python3: %global __python3 /usr/bin/python3}
%{!?python3_pkgversion:%global python3_pkgversion 3}
%endif

%if %{undefined python3_sitelib}
%if "%{_vendor}" == "debbuild"
%global python3_sitelib %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
%else
%global python3_sitelib %(%{__python3} -c "import sysconfig; print(sysconfig.get_path('platlib'))")
%endif
%endif

%if %{undefined python3_version}
%global python3_version %(%{__python3} -Esc "import sys; sys.stdout.write('{0.major}.{0.minor}'.format(sys.version_info))")
%endif

%if %{undefined python3_version_nodots}
%global python3_version_nodots %(%{__python3} -Esc "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))")
%endif

%if 0%{?debian} || 0%{?ubuntu}
%global is_deb 1
%global pygroup python
%global sysgroup admin
%global develsuffix dev
%else
%global pygroup Development/Languages/Python
%global sysgroup System/Management
%global develsuffix devel
%endif

Name:           python-kiwi_boxed_plugin
Version:        0.2.56
Release:        0
Url:            https://github.com/OSInside/kiwi-boxed-plugin
Summary:        KIWI - Boxed Build Plugin
License:        GPL-3.0-or-later
%if "%{_vendor}" == "debbuild"
# Needed to set Maintainer in output debs
Packager:       Marcus Schaefer <marcus.schaefer@suse.com>
%endif
Group:          %{pygroup}
Source:         python-kiwi-boxed-plugin.tar.gz
Source1:        %{name}-rpmlintrc
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
# Main build requirements
BuildRequires:  python%{python3_pkgversion}-%{develsuffix}
BuildRequires:  python%{python3_pkgversion}-build
BuildRequires:  python%{python3_pkgversion}-installer
BuildRequires:  python%{python3_pkgversion}-poetry-core >= 1.2.0
BuildRequires:  python%{python3_pkgversion}-wheel
# doc build requirements
%if ! (0%{?fedora} >= 41 || 0%{?rhel} >= 10)
BuildRequires:  python%{python3_pkgversion}-docopt >= 0.6.2
%else
BuildRequires:  python%{python3_pkgversion}-docopt-ng
%endif
BuildRequires:  python%{python3_pkgversion}-requests
%if 0%{?suse_version}
BuildRequires:  python%{python3_pkgversion}-Sphinx
%else
BuildRequires:  python%{python3_pkgversion}-sphinx
%endif
%if 0%{?debian} || 0%{?ubuntu}
BuildRequires:  python%{python3_pkgversion}-sphinx-rtd-theme
BuildRequires:  python%{python3_pkgversion}-yaml
%else
BuildRequires:  python%{python3_pkgversion}-sphinx_rtd_theme
BuildRequires:  python%{python3_pkgversion}-PyYAML
%endif
%if 0%{?fedora} || 0%{?suse_version}
BuildRequires:  fdupes
%endif
BuildArch:      noarch

%description
The KIWI boxed plugin provides support for self contained building
of images based on fast booting VM images

# python3-kiwi_boxed_plugin
%package -n python%{python3_pkgversion}-kiwi_boxed_plugin
Summary:        KIWI - Boxed Build Plugin
Group:          %{pygroup}
%if 0%{?ubuntu} || 0%{?debian}
Requires:       kiwi >= 9.21.21
%else
Requires:       python%{python3_pkgversion}-kiwi >= 9.21.21
%endif
Requires:       python%{python3_pkgversion} >= 3.9
Requires:       python%{python3_pkgversion}-docopt
Requires:       python%{python3_pkgversion}-requests
Requires:       python%{python3_pkgversion}-progressbar2
%if 0%{?ubuntu} || 0%{?debian}
Requires:       python%{python3_pkgversion}-yaml
%else
Requires:       python%{python3_pkgversion}-PyYAML
%endif
%if 0%{?suse_version}
Requires:       python%{python3_pkgversion}-Cerberus
%else
Requires:       python%{python3_pkgversion}-cerberus
%endif
%if 0%{?ubuntu} || 0%{?debian}
Requires:       qemu-kvm
%else
Requires:       qemu
%endif
Recommends:     sshfs
Recommends:     virtiofsd >= 1.10

%description -n python%{python3_pkgversion}-kiwi_boxed_plugin
The KIWI boxed plugin provides support for self contained building
of images based on fast booting VM images

%prep
%setup -q -n kiwi_boxed_plugin-%{version}

# Temporarily switch things back to docopt for everything but Fedora 41+
# FIXME: Drop this hack as soon as we can...
%if ! (0%{?fedora} >= 41 || 0%{?rhel} >= 10)
sed -e 's/docopt-ng.*/docopt = ">=0.6.2"/' -i pyproject.toml
%endif

# Build documentation
make -C doc man

# Build application wheel
%{__python3} -m build --no-isolation --wheel

%install
# Install plugin
%{__python3} -m installer --destdir %{buildroot} %{?is_deb:--no-compile-bytecode} dist/*.whl

%if 0%{?is_deb}
# Fix where files were installed
mv %{buildroot}%{_prefix}/local/* %{buildroot}%{_prefix}
mv %{buildroot}%{_prefix}/lib/python3* %{buildroot}%{_prefix}/lib/python3
%endif

# Install man pages and package documentation
make buildroot=%{buildroot}/ docdir=%{_defaultdocdir}/ install

%files -n python%{python3_pkgversion}-kiwi_boxed_plugin
%dir %{_defaultdocdir}/python-kiwi_boxed_plugin
%{python3_sitelib}/kiwi_boxed_plugin*
%{_defaultdocdir}/python-kiwi_boxed_plugin/LICENSE
%{_defaultdocdir}/python-kiwi_boxed_plugin/README
%doc %{_mandir}/man8/*

%changelog
openSUSE Build Service is sponsored by