File python-openstackclient.spec of Package python-openstackclient

%{!?upstream_version: %global upstream_version %{version}%{?milestone}}

%bcond_with python2
%bcond_with python3
%bcond_without test
%bcond_without docs

%global client openstackclient

Name:             python-openstackclient
Version:          5.3.1
Release:          1%{?dist}
Summary:          OpenStack Command-line Client

License:          Apache-2.0
URL:              http://github.com/openstack/%{name}
Source0:          https://tarballs.openstack.org/%{name}/%{name}-%{upstream_version}.tar.gz

BuildArch:        noarch

%description
python-openstackclient is a unified command-line client for the OpenStack APIs.
It is a thin wrapper to the stock python-*client modules that implement the
actual REST API client actions.

%package -n python-%{client}-doc
Summary:          Documentation for OpenStack Command-line Client

# BuildRequires:    python-sphinx
# BuildRequires:    python-openstackdocstheme
# BuildRequires:    python2-sphinxcontrib-apidoc

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

%description -n python-%{client}-doc
python-openstackclient is a unified command-line client for the OpenStack APIs.
It is a thin wrapper to the stock python-*client modules that implement the
actual REST API client actions.

This package contains auto-generated documentation.

%package  -n python-%{client}-lang
Summary:   Translation files for Openstackclient

%description -n python-%{client}-lang
Translation files for Openstackclient

%if %{with python3}
%package -n python3-%{client}
Summary:    OpenStack Command-line Client
%{?python_provide:%python_provide python3-%{client}}

BuildRequires:    python3-devel
BuildRequires:    python3-setuptools
BuildRequires:    python3-pbr
BuildRequires:    python3-six
BuildRequires:    python3-cliff >= 2.8.0
BuildRequires:    python3-osc-lib >= 2.0.0
BuildRequires:    python3-openstacksdk >= 0.48.0
BuildRequires:    python3-oslo-i18n >= 3.15.3
BuildRequires:    python3-oslo-utils >= 3.33.0
BuildRequires:    python3-keystoneclient
BuildRequires:    python3-novaclient
BuildRequires:    python3-cinderclient
BuildRequires:    python3-stevedore >= 2.1.0
# Required to compile translation files
#BuildRequires:    python3-babel
%if %{with test}
# Required for unit tests
BuildRequires:    python3-os-testr
BuildRequires:    python3-osc-lib-tests
BuildRequires:    python3-coverage
BuildRequires:    python3-fixtures
BuildRequires:    python3-oslotest
BuildRequires:    python3-reno
BuildRequires:    python3-requestsexceptions
BuildRequires:    python3-openstacksdk
BuildRequires:    python3-osprofiler
%endif # test

%if %{with docs}
BuildRequires:    python3-sphinx
%endif

Requires:         python3-pbr
Requires:         python3-cliff >= 2.8.0
Requires:         python3-openstacksdk >= 0.48.0
Requires:         python3-oslo-i18n >= 3.15.3
Requires:         python3-oslo-utils >= 3.33.0
Requires:         python3-keystoneclient >= 1:3.8.0
Requires:         python3-novaclient >= 1:9.0.0
Requires:         python3-cinderclient >= 3.1.
Requires:         python3-six >= 1.9.0
Requires:         python3-osc-lib >= 2.0.0
#Requires:         python-%{client}-lang = %{version}-%{release}

%description -n python3-%{client}
python-openstackclient is a unified command-line client for the OpenStack APIs.
It is a thin wrapper to the stock python-*client modules that implement the
actual REST API client actions.
%endif # with python3

%prep
%autosetup -n %{name}-%{upstream_version}

# We handle requirements ourselves, pkg_resources only bring pain
rm -rf requirements.txt test-requirements.txt

%build
%if %{with python3}
%py3_build
%endif
#%{__python3} setup.py compile_catalog -d build/lib/openstackclient/locale

%install
%if %{with python3}
%py3_install
mv %{buildroot}%{_bindir}/openstack %{buildroot}%{_bindir}/openstack-3
#ln -s ./openstack-3 %{buildroot}%{_bindir}/openstack-3
ln -s ./openstack-3 %{buildroot}%{_bindir}/openstack
%endif

#%{__python2} setup.py install -O1 --skip-build --root %{buildroot}
#ln -s ./openstack %{buildroot}%{_bindir}/openstack-2
#ln -s ./openstack %{buildroot}%{_bindir}/openstack-%{python2_version}

%if %{with docs}
sphinx-build -b html doc/source doc/build/html
sphinx-build -b man doc/source doc/build/man

install -p -D -m 644 doc/build/man/openstack.1 %{buildroot}%{_mandir}/man1/openstack.1

# Fix hidden-file-or-dir warnings
rm -fr doc/build/html/.doctrees doc/build/html/.buildinfo
%endif # with docs

# Install i18n .mo files (.po and .pot are not required)
install -d -m 755 %{buildroot}%{_datadir}
rm -f %{buildroot}%{python3_sitelib}/openstackclient/locale/*/LC_*/openstackclient*po
rm -f %{buildroot}%{python3_sitelib}/openstackclient/locale/*pot
mv %{buildroot}%{python3_sitelib}/openstackclient/locale %{buildroot}%{_datadir}/locale

%if %{with python3}
rm -rf %{buildroot}%{python3_sitelib}/openstackclient/locale
%endif

# Find language files
#%find_lang openstackclient --all-name

%check
%if %{with test}
%if %{with python3}
rm -rf .testrepository
# NOTE(jpena): We are getting some test failures with Python 3.7. Ignore while we figure out the reason
PYTHON=python3 %{__python3} setup.py test || true
%endif # python3
%endif # test

%if %{with docs}
%files -n python-%{client}-doc
%license LICENSE
%doc doc/build/html
%endif # with docs

#%files -n python-%{client}-lang -f %{client}.lang
#%license LICENSE

%if %{with python3}
%files -n python3-%{client}
%license LICENSE
%doc README.rst
%{_bindir}/openstack
%{_bindir}/openstack-3
%{python3_sitelib}/openstackclient
%{python3_sitelib}/*.egg-info
%endif

%changelog
openSUSE Build Service is sponsored by