File python-mpservlets.spec of Package python-mpservlets

#
# spec file for package python-mpservlets
#
# Copyright (c) 2011 SUSE LINUX Products 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_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%{!?python_sitearch: %global python_sitearch %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}

%define mod_name mpservlets

Name:           python-%{mod_name}
Version:        1.1.6
Release:        28
License:        Apache-2.0
Summary:        Mod_python Servlets - a mod_python handler
Url:            http://pypi.python.org/pypi/mpservlets
Group:          Development/Languages/Python
Source:         %{mod_name}-%{version}.tar.bz2
BuildRequires:  python-devel
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version}
BuildRequires:  apache2-devel
%py_requires
%if 0%{?suse_version} > 1110
BuildRequires:  fdupes
BuildArch:      noarch
%endif
%else
BuildRequires:  apache-devel
%endif
%define         apache_serverroot %(/usr/sbin/apxs2 -q DATADIR)
%define         apache_sysconfdir %(/usr/sbin/apxs2 -q SYSCONFDIR)

%description
A mod_python handler that uses instances of subclasses of class Servlet (thus
its name) to respond to HTTP GET and POST requests. For each request a series
of methods are called on the instance, the output of such being sent to the
client as the response. This handler was inspired by WebWare.

%package doc
License:        Apache-2.0
Summary:        API Reference in HTML and PDF
Group:          Documentation/Other
Requires:       %{name} = %{version}

%description doc
This package contains the API Reference in HTML and PDF for %{name}.

This documentation is generated using epydoc (http://epydoc.sourceforge.net)
which uses simple, special markup in python doc strings, so the source code is
well documented as well.

%package tutorial
License:        Apache-2.0
Summary:        A tutorial on developing web applications using servlets
Group:          Documentation/Other
Requires:       %{name} = %{version}

%description tutorial
This package contains a tutorial on developing web applications using %{name}.

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

%build

%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}
# install documentation
mkdir -p %{buildroot}/%_defaultdocdir/%{name}
install -m644 README LICENSE %{buildroot}/%_defaultdocdir/%{name}/
cp -r Doc %{buildroot}/%_defaultdocdir/%{name}/
# install the tutorial
mkdir -p %{buildroot}/%{apache_serverroot}/%{name}-tutorial
cp -r tutorial/* %{buildroot}/%{apache_serverroot}/%{name}-tutorial/
# install an apache config
mkdir -p %{buildroot}/%{apache_sysconfdir}/conf.d/
cat > %{buildroot}/%{apache_sysconfdir}/conf.d/%{name}-tutorial.conf << EOF
Alias /mps_tutorial %{apache_serverroot}/%{name}-tutorial
<Directory %{apache_serverroot}/%{name}-tutorial>
  <IfModule mod_python.c>
    SetHandler mod_python
    PythonHandler mod_python.servlet
    PythonDebug on
  </IfModule>
  order allow,deny
  allow from all
</Directory>
EOF
%if 0%{?suse_version} > 1110
%fdupes %{buildroot}/%_defaultdocdir
%endif

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root,-)
%dir %_defaultdocdir/%{name}
%doc %_defaultdocdir/%{name}/README
%doc %_defaultdocdir/%{name}/LICENSE
%python_sitelib/*

%files doc
%defattr(-,root,root)
%_defaultdocdir/%{name}/Doc

%files tutorial
%defattr(-,root,root)
%config(noreplace) %{apache_sysconfdir}/conf.d/%{name}-tutorial.conf
%{apache_serverroot}/%{name}-tutorial

%changelog
openSUSE Build Service is sponsored by