[Bug 1538341] Review Request: python-testinfra - unit testing for server state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



https://bugzilla.redhat.com/show_bug.cgi?id=1538341



--- Comment #3 from Robert-André Mauchin <zebob.m@xxxxxxxxx> ---
 - It's not needed to duplicate the source code to do both python2 and python3
builds.

 - Not needed in %install: rm -rf $RPM_BUILD_ROOT

 - package name should be: python-%{pkgname} with two subpackages %package    
-n python2-testinfra and %package     -n python3-testinfra

 - No need for these custom macros setup_cmd_p2/setup_cmd_p3, just use the
normal macros and pass your variables to them.

 - Use a more meaningful name for your archive with:

Source0:       
https://github.com/philpep/%{pkgname}/archive/%{version}/%{pkgname}-%{version}.tar.gz

 - You include doc in %doc but you didn't build the doc with sphinx first, what
you're really doing is adding source files for the doc.

# generate html docs 
sphinx-build doc/source html
# remove the sphinx-build leftovers
rm -rf html/.{doctrees,buildinfo}

 - you did not include %{?python_provide:%python_provide


Here's my take on it:


%{!?__python2: %global __python2 %__python}
%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from
distutils.sysconfig import get_python_lib; print(get_python_lib())")}

%if 0%{?fedora}
%bcond_without python3
%else
%bcond_with python3
%endif

%global pkgname testinfra

Name:           python-%{pkgname}
Version:        1.10.1
Release:        1%{?dist}
Summary:        Unit testing for config-managed server state

License:        ASL 2.0
URL:            https://github.com/philpep/%{pkgname}
Source0:        %{url}/archive/%{version}/%{pkgname}-%{version}.tar.gz

BuildArch:      noarch

BuildRequires:  python2-devel
BuildRequires:  python2-pbr

# testing requirements
BuildRequires:  python2-mock
BuildRequires:  python2-six
BuildRequires:  python2-pytest
BuildRequires:  python2-pytest-xdist
BuildRequires:  python2-pytest-cov
BuildRequires:  python2-winrm
BuildRequires:  python2-paramiko
BuildRequires:  salt

%if %{with python3}
BuildRequires:  python3-devel
BuildRequires:  python3-pbr

# testing requirements
BuildRequires:  python3-mock
BuildRequires:  python3-six
BuildRequires:  python3-pytest
BuildRequires:  python3-pytest-xdist
BuildRequires:  python3-pytest-cov
BuildRequires:  python3-winrm
BuildRequires:  python3-paramiko
%endif # with python3

%if %{with python3}
BuildRequires:  python3-sphinx
%else
BuildRequires:  python2-sphinx
%endif # with python3

%description
With Testinfra you can write unit tests in Python to test actual state of your
servers configured by management tools like Salt, Ansible, Puppet, Chef and so
on.

Testinfra aims to be a Serverspec equivalent in python and is written as a
plugin to the powerful Pytest test engine


%package     -n python2-%{pkgname}
Summary:        Unit testing for config-managed server state
%{?python_provide:%python_provide python2-%{pkgname}}

%description -n python2-%{pkgname}
With Testinfra you can write unit tests in Python to test actual state of your
servers configured by management tools like Salt, Ansible, Puppet, Chef and so
on.

Testinfra aims to be a Serverspec equivalent in python and is written as a
plugin to the powerful Pytest test engine


%if %{with python3}
%package     -n python3-%{pkgname}
Summary:        Unit testing for config-managed server state
%{?python_provide:%python_provide python3-%{pkgname}}

%description -n python3-%{pkgname}
With Testinfra you can write unit tests in Python to test actual state of your
servers configured by management tools like Salt, Ansible, Puppet, Chef and so
on.

Testinfra aims to be a Serverspec equivalent in python and is written as a
plugin to the powerful Pytest test engine

%endif # with python3


%prep
%autosetup -n %{pkgname}-%{version}

%build
SKIP_PIP_INSTALL=1 PBR_VERSION=%{version} %py2_build
%if %{with python3}
SKIP_PIP_INSTALL=1 PBR_VERSION=%{version} %py3_build
%endif # with python3

# generate html docs 
sphinx-build doc/source html
# remove the sphinx-build leftovers
rm -rf html/.{doctrees,buildinfo}


%install
SKIP_PIP_INSTALL=1 PBR_VERSION=%{version} %py2_install
%if %{with python3}
SKIP_PIP_INSTALL=1 PBR_VERSION=%{version} %py3_install
%endif # with python3


%check
SKIP_PIP_INSTALL=1 PBR_VERSION=%{version} %{__python2} setup.py test

%files -n python2-%{pkgname}
%license LICENSE
%doc html *.rst
%if %{without python3}
%{_bindir}/%{pkgname}
%endif # without python3
%{python2_sitelib}/%{pkgname}
%{python2_sitelib}/%{pkgname}-%{version}-py?.?.egg-info

%if %{with python3}
%files -n python3-%{pkgname}
%license LICENSE
%doc html *.rst
%{_bindir}/%{pkgname}
%{python3_sitelib}/%{pkgname}
%{python3_sitelib}/%{pkgname}-%{version}-py?.?.egg-info
%endif # with python3


%changelog
* Wed Jan 24 2018 Brett Lentz <brett.lentz@xxxxxxxxx> - 1.10.1-1
- initial package

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are always notified about changes to this product and component
_______________________________________________
package-review mailing list -- package-review@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to package-review-leave@xxxxxxxxxxxxxxxxxxxxxxx




[Index of Archives]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite Conditions]     [KDE Users]

  Powered by Linux