# If any of the following macros should be set otherwise,
# you can wrap any of them with the following conditions:
# - %%if 0%%{?centos} == 7
# - %%if 0%%{?rhel} == 7
# - %%if 0%%{?fedora} == 23
# Or just test for particular distribution:
# - %%if 0%%{?centos}
# - %%if 0%%{?rhel}
# - %%if 0%%{?fedora}
#
# Be aware, on centos, both %%rhel and %%centos are set. If you want to test
# rhel specific macros, you can use %%if 0%%{?rhel} && 0%%{?centos} == 0 condition.
# (Don't forget to replace double percentage symbol with single one in order to apply a condition)

%undefine _enable_debug_packages

%global provider        github
%global provider_tld    com
%global project         containers
%global repo            libpod
# https://github.com/containers/libpod
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
%global import_path     %{provider_prefix}
%global commit          #COMMIT#
%global shortcommit     %(c=%{commit}; echo ${c:0:7})

Name:           python3-podman
Version:        0.7.3
Release:        #COMMITDATE#.git%{shortcommit}%{?dist}
Summary:        Python 3 bindings and client for podman
License:        ASL 2.0
URL:            https://%{provider_prefix}
Source0:        https://api.%{provider}.%{provider_tld}/repos/%{project}/%{repo}/tarball/%{commit}

BuildArch: noarch
BuildRequires: git
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-varlink

Requires: python3-humanize
Requires: python3-pytoml
Requires: python3-setuptools
Requires: python3-varlink
Requires: python3-psutil
Requires: podman

%if 0%{?fedora}
# 2018-07-20 RHEL8 doesn't have varlink RPM yet
Requires: python3-varlink
%endif

Provides: %{name} = %{version}-%{release}

%description
%{summary}
python3-podman provides python bindings and client for communicating
with podman as a service.

%prep
%autosetup -Sgit -n %{project}-%{repo}-%{shortcommit}

%build
export PODMAN_VERSION=%{version}

pushd contrib/python/podman
%{__python3} setup.py build
popd

pushd contrib/python/pypodman
%{__python3} setup.py build
popd

%install
export PODMAN_VERSION=%{version}

install -d -m 755 %{buildroot}%{_mandir}/man1

pushd contrib/python/pypodman
install -m 644 -t %{buildroot}%{_mandir}/man1 docs/man1/*.1
%{__python3} setup.py install --skip-build --root %{buildroot}
popd

pushd contrib/python/podman
%{__python3} setup.py install --skip-build --root %{buildroot}
popd


%check
#define license tag if not already defined
%{!?_licensedir:%global license %doc}

%files
%license LICENSE
%doc README.md CONTRIBUTING.md install.md code-of-conduct.md transfer.md
%{_bindir}/pypodman
%{_mandir}/man1/pypodman.1*
%dir %{python3_sitelib}/podman
%dir %{python3_sitelib}/pypodman
%{python3_sitelib}/podman/*
%{python3_sitelib}/pypodman/*
%{python3_sitelib}/podman-%{version}*.egg-info
%{python3_sitelib}/pypodman-%{version}*.egg-info

%changelog
