%global debug_package %{nil}
%global srcname Werkzeug

Name:           python-werkzeug
Summary:        A comprehensive WSGI web application library
Version:        0.14.1
Release:        5
License:        BSD
URL:            http://werkzeug.pocoo.org/
Source0:        https://files.pythonhosted.org/packages/source/W/Werkzeug/%{srcname}-%{version}.tar.gz
# Pypi version of werkzeug is missing _themes folder needed to build werkzeug sphinx docs
# See https://github.com/mitsuhiko/werkzeug/issues/761
Source1:        werkzeug-sphinx-theme.tar.gz

# https://github.com/pallets/werkzeug/pull/1293
# skip tests that use a fixture called 'subprocess' when pytest-xprocess
# is not installed
Patch0:         Skip-tests-that-use-xprocess-fixture-when-not-installed.patch

%global _description\
Werkzeug is a comprehensive WSGI web application library. It began as a\
simple collection of various utilities for WSGI applications and has\
become one of the most advanced WSGI utility libraries.\
It includes:\
* An interactive debugger that allows inspecting stack traces and source\
code in the browser with an interactive interpreter for any frame in the stack.\
* A full-featured request object with objects to interact with headers,\
query args, form data, files, and cookies.\
* A response object that can wrap other WSGI applications and handle\
streaming data.\
* A routing system for matching URLs to endpoints and generating URLs for\
endpoints, with an extensible system for capturing variables from URLs.\
* HTTP utilities to handle entity tags, cache control, dates, user agents,\
cookies, files, and more.\
* A threaded WSGI server for use while developing applications locally.\
* A test client for simulating HTTP requests during testing without\
requiring running a server.\
Werkzeug is Unicode aware and doesn't enforce any dependencies. It is up\
to the developer to choose a template engine, database adapter, and even\
how to handle requests. It can be used to build all sorts of end user\
applications such as blogs, wikis, or bulletin boards.\

%description %_description

%package -n python2-werkzeug
Summary: %summary

BuildRequires:  python2-devel python2-setuptools git
# For tests
BuildRequires:  python2-pytest python2-hypothesis python2-requests python2-pyOpenSSL
BuildRequires:  python2-greenlet python2-redis

%{?python_provide:%python_provide python2-werkzeug}

%description -n python2-werkzeug %_description

%package -n python2-werkzeug-doc
Summary:        Documentation for %{name}
BuildRequires:  python2-sphinx
Requires:       python2-werkzeug = %{version}-%{release}
%{?python_provide:%python_provide python2-werkzeug-doc}

%description -n python2-werkzeug-doc
Documentation and examples for %{name}.


%package -n python3-werkzeug
Summary:        %summary

BuildRequires:  python3-devel python3-setuptools git
# For tests
BuildRequires:  python3-pytest python3-hypothesis python3-requests python3-pyOpenSSL
BuildRequires:  python3-greenlet python3-redis

%{?python_provide:%python_provide python3-werkzeug}

%description -n python3-werkzeug %_description


%package -n python3-werkzeug-doc
Summary:        Documentation for python3-werkzeug
BuildRequires:  python3-sphinx
Requires:       python3-werkzeug = %{version}-%{release}
%{?python_provide:%python_provide python3-werkzeug-doc}

%description -n python3-werkzeug-doc
Documentation and examples for python3-werkzeug.


%prep
%autosetup -n %{srcname}-%{version} -p1 -Sgit
%{__sed} -i 's/\r//' LICENSE
%{__sed} -i '1d' tests/multipart/test_collect.py
tar -xf %{SOURCE1}

rm -rf %{py3dir}
cp -a . %{py3dir}
find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|'


%build
werkzeug_build() {
	find examples/ -name '*.py' -executable | xargs chmod -x
	find examples/ -name '*.png' -executable | xargs chmod -x
	pushd docs
	# Add a symlink to the dir with the Python module so that __version__ can be
	# obtained therefrom.
	ln -s ../werkzeug werkzeug
	make html
	popd
}

%py2_build
werkzeug_build

pushd %{py3dir}
%py3_build
werkzeug_build
popd


%install
werkzeug_install() {
	%{__rm} -rf docs/_build/html/.buildinfo
	%{__rm} -rf examples/cupoftee/db.pyc
}
%py2_install
werkzeug_install

pushd %{py3dir}
%py3_install
werkzeug_install
popd

%check
PYTHONPATH=./ py.test-2

pushd %{py3dir}
PYTHONPATH=./ py.test-3
popd

%files -n python2-werkzeug
%license LICENSE AUTHORS
%doc PKG-INFO CHANGES.rst
%{python2_sitelib}/*

%files -n python2-werkzeug-doc
%doc docs/_build/html examples

%files -n python3-werkzeug
%license LICENSE AUTHORS
%doc PKG-INFO CHANGES.rst
%{python3_sitelib}/*

%files -n python3-werkzeug-doc
%doc docs/_build/html examples


%changelog
* Mon Nov 4 2019 openEuler Buildteam <buildteam@openeuler.org> - 0.14.1-4
- Package init
