File python-ua-parser.spec of Package python-ua-parser

#
# spec file for package python-ua-parser
#
# Copyright (c) 2018 SUSE LINUX 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 http://bugs.opensuse.org/
#


%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%bcond_without test

%define pyname uap-python

Name:           python-ua-parser
Version:        0
Release:        0
Summary:        Python implementation of ua-parser
License:        Apache-2.0
Group:          Development/Languages/Python
Url:            https://github.com/ua-parser/uap-python
Source0:        %{pyname}-%{version}.tar.xz
BuildRequires:  python-rpm-macros
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module setuptools}
BuildRequires:  %{python_module packaging}
BuildRequires:  %{python_module PyYAML}
BuildRequires:  fdupes

#tests
%if %{with test}
BuildRequires:  %{python_module virtualenv >= 14.0.0}
BuildRequires:  %{python_module pytest}
BuildRequires:  %{python_module tox}
%endif
BuildArch:      noarch

%python_subpackages

%description
A python implementation of the UA Parser (https://github.com/ua-parser, formerly https://github.com/tobie/ua-parser)

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

%build
%python_build

%install
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}

%if %{with test}
%check
%{python_expand virtualenv-%$python_bin_suffix --system-site-packages --no-download testvenv-%$python_bin_suffix
testvenv-%$python_bin_suffix/bin/pip install -e .[test,build]
export PYTHONPATH=$PWD/testvenv-%$python_bin_suffix/lib/python%$python_bin_suffix/site-packages/:$PWD
testvenv-%$python_bin_suffix/bin/python -m pytest && rm -Rf testvenv-%$python_bin_suffix
}
%endif

%files %{python_files}
%defattr(-,root,root,-)
%license ua_parser/LICENSE
%doc README.rst
%{python_sitelib}/*

%changelog
openSUSE Build Service is sponsored by