File apache2-mod_python.spec of Package apache2-mod_python

#
# spec file for package apache2-mod_python
#
# Copyright (c) 2016 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/
#


%define modname mod_python
Name:           apache2-mod_python
Version:        3.5.0
Release:        0
Summary:        A Python Module for the Apache 2 Web Server
License:        Apache-2.0
Group:          Productivity/Networking/Web/Servers

Url:            http://www.modpython.org/
Source:         %{modname}-%{version}.tar.bz2

# Aggregated commit # since 3.5.0 release / commit SHA
# 001/75fdcbd50ef2ffda071cd26d4495c817814fc864 - News
# 002/976a674b42f9647865d40fa417e7a3dc56a16e6e p Version
# 003/06f994ad439aacdf79ec52d3e997038dfad8aeac p 3.3.1 semantics/cookie expiration
# 004/a09ab44204227d223c382d0293aab6d2c3577d25 - Typo
# 005/8322c725426d9d615e7b1b6fc18e3bb664038508 - print syntax
# 006/8b4850d22e177a9f4d3586940c92bfeb7c96e1c1 p Allow None as value for req.args
# 007/7bf939b1c1b81c2fd84859e82e4c8b60c65d01fa - tests
# 008/0a39fe5b39835d3dca9ca75febe036545803b47f p apxsflags
# 009/7de9a6b583334aa000d99f60fff92d7924eecf2f p user site dir
# 010/aa9e288e661a3e3d7c3d572b193f00ce28f82a51 - destdir
# 011/9d4874c9fa9b6e80c252a9ac91444d39a9a93770 - utf8/encoding/python3
# 012/11c5e5a06d168aadbd7d574a5a6ff65bf6cd006c - version
# 013/2a42e864d354c2aae1ced1a04698546d2ac494b5 - bin location
# 014/e995e0370030e788f6e18d007708c30001b50b0c - Doc distclean
# 015/5bb5d6d0113f6bbd72966a5c1f3e6d40c2e9c8fd p fix import / graceful restart
# 016/8da41b9668ce7c5a2c3d17fb0441bb17e72957cf p dbm/psp

# PATCH-FIX-UPSTREAM -- Fixes for compiling without git
Patch002:       mod_python-3.5.0-002-976a674-version.patch
Patch003:       mod_python-3.5.0-003-06f994a-cookie_expiration.patch
Patch006:       mod_python-3.5.0-006-8b4850d-req_args_none.patch
Patch008:       mod_python-3.5.0-008-0a39fe5-apxsflags.patch
Patch009:       mod_python-3.5.0-009-7de9a6b-no_user_site_dir.patch
Patch015:       mod_python-3.5.0-015-5bb5d6d-site_import.patch
Patch016:       mod_python-3.5.0-016-8da41b9-dbm_psp.patch

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  apache2-devel
BuildRequires:  apache-rpm-macros
BuildRequires:  autoconf
BuildRequires:  bison
BuildRequires:  flex
BuildRequires:  fdupes
BuildRequires:  gcc
BuildRequires:  glibc-devel
BuildRequires:  make
BuildRequires:  pcre-devel
BuildRequires:  python-devel

# temporary for tests
BuildRequires:  apache2-mod_python

Requires:       %{apache_mmn}
Requires:       %{apache_suse_maintenance_mmn}
Requires:       apache2
Conflicts:      mod_python

%py_requires

%description
mod_python allows embedding Python within the Apache HTTP server for a
considerable boost in performance and added flexibility in designing
Web-based applications.

Apache processes requests in stages (for example: read the request,
parse headers, check access, and so on). These stages can be
implemented by functions called handlers. Traditionally, handlers are
written in C and compiled into Apache modules. mod_python provides a
way to extend Apache functionality by writing Apache handlers in
Python. For a detailed description of the Apache request processing
process, see the Apache API notes.

For most programmers, the request and the authentication handlers
provide everything required. To ease migration from CGI and Httpdapy,
two handlers are provided that simulate these environments, allowing a
user to run scripts under mod_python with (for the most part) no
changes to the code.

mod_python originated from a project called Httpdapy. For a long time,
Httpdapy was not called mod_python because Httpdapy was not meant to be
Apache-specific. Httpdapy was designed to be cross-platform and was
initially written for the Netscape server.

Usage Hints:

To load mod_python into Apache, add it to APACHE_MODULES in
%{_sysconfdir}/sysconfig/apache2. The configuration is described in
%{_docdir}/%{name}/doc-html/index.html (see %{name}-doc package).


%package doc
Summary:        Documentation for mod_python
Group:          Productivity/Networking/Web/Servers

%description doc
mod_python allows embedding Python within the Apache HTTP server for a
considerable boost in performance and added flexibility in designing
Web-based applications.

This package contains the documentation for mod_python.
The configuration is described in %{_docdir}/%{name}/doc-html/index.html.


%prep
%setup -q -n %{modname}-%{version}
%patch002 -p1
%patch003 -p1
%patch006 -p1
%patch008 -p1
%patch009 -p1
%patch015 -p1
%patch016 -p1

#case %{_lib} in
#    lib) ;;
#    *) mv lib %{_lib};;
#esac

#sed -i 's@lib/python@%{_lib}/python@' configure.in

#sed -i "
#s@setup.py install@setup.py install --prefix=%{_prefix} --root=%{buildroot}@
#;
#s@/lib@/%{_lib}@
#" dist/Makefile.in

#sed -i "
#s@setup.py install@setup.py install --prefix=%{_prefix} --root=%{buildroot}@
#;
#s@'lib'@'%{_lib}'@
#" dist/setup.py.in

# for test.py
#sed -i '/test:/ a \
#    PYTHONPATH="../lib/python" python test.py' test/Makefile.in

#sed -i 's@\
#    \$(PYTHON_BIN) test.py@\
#    PYTHONPATH="../lib/python" python test.p@' test/Makefile.in

# remove cruft
find doc-html/ -name .buildinfo -delete

%build
%configure \
    --libdir="%{_libdir}" \
    --with-apxs="%{apache_apxs}" \
    --with-mutex-dir="%{_rundir}/%{name}" \
    --with-python="%{_bindir}/python"

make OPT="%{apache_cflags}" %{?_smp_mflags}

%install
install -d %{buildroot}/%{_bindir}
make DESTDIR=%{buildroot} install %{?_smp_mflags}

%fdupes %{buildroot}%{python_sitearch}/%{modname}

%check
set +x
%apache_test_module_load -m python
make test
set -x
#rm -r test
#sed -i "s@%{_buildroot}/src@b%{apache_libexecdir}g" lib/python/%{modname}/version.py
#sed -i "s@%{_buildroot}/test@%{python_sitearch}/%{modname}/test@" lib/python/%{modname}/version.py

%files
%defattr(-,root,root)
%doc COPYRIGHT CREDITS NEWS
%{apache_libexecdir}/%{modname}.so
%{python_sitearch}/%{modname}*
%{_bindir}/%{modname}

%files doc
%defattr(-,root,root)
%doc doc-html/

%changelog