]> git.pld-linux.org Git - projects/template-specs.git/commitdiff
py3 samples, rather dirty and unorganized
authorElan Ruusamäe <glen@delfi.ee>
Fri, 5 Apr 2013 22:03:33 +0000 (01:03 +0300)
committerElan Ruusamäe <glen@delfi.ee>
Fri, 5 Apr 2013 22:03:33 +0000 (01:03 +0300)
python.spec

index 717f5e10543e1bfe6cd513b6fd57507726bcdf57..ba54006e29cfcef8613f1b3ecdb0d11932a0ee01 100644 (file)
@@ -1,6 +1,7 @@
 #
 # Conditional build:
 %bcond_without tests   # do not perform "make test"
+%bcond_without python3 # CPython 3.x module
 
 %define        module  template
 Summary:       -
@@ -20,6 +21,13 @@ BuildRequires:       python-distribute
 BuildRequires: rpm-pythonprov
 # if py_postclean is used
 BuildRequires: rpmbuild(macros) >= 1.219
+# when python3 present
+BuildRequires: sed >= 4.0
+%if %{with python3}
+BuildRequires: python3-devel
+BuildRequires: python3-distribute
+BuildRequires: python3-modules
+%endif
 #Requires:             python-libs
 Requires:              python-modules
 #BuildArch:    noarch
@@ -29,20 +37,63 @@ BuildRoot:  %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
 %description -l pl.UTF-8
 
+%package apidoc
+Summary:       %{module} API documentation
+Summary(pl.UTF-8):     Dokumentacja API %{module}
+Group:         Documentation
+
+%description apidoc
+API documentation for %{module}.
+
+%description apidoc -l pl.UTF-8
+Dokumentacja API %{module}.
+
 %prep
 %setup -q -n %{module}-%{version}
 
 # fix #!/usr/bin/env python -> #!/usr/bin/python:
 #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
 
+%if %{with python3}
+rm -rf build-3
+set -- *
+install -d build-3
+cp -a "$@" build-3
+find build-3 -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|'
+%endif
+
 %build
+%if %{with python2}
+%{__python} setup.py build --build-base build-2
+%endif
+%if %{with python3}
+%{__python3} setup.py build --build-base build-3
+%endif
+
 # CC/CFLAGS is only for arch packages - remove on noarch packages
 CC="%{__cc}" \
 CFLAGS="%{rpmcflags}" \
 %{__python} setup.py build
+%{__python} setup.py \
+       build -b build-2
 
 %{?with_tests:%{__python} setup.py test}
 
+%if %{with python3}
+%{__python3} setup.py \
+       build -b build-3
+
+%if %{with tests}
+%{__python3} setup.py test
+%endif
+%endif
+
+%if %{with doc}
+cd docs
+%{__make} -j1 html
+rm -rf _build/html/_sources
+%endif
+
 %install
 rm -rf $RPM_BUILD_ROOT
 %{__python} setup.py install \
@@ -50,6 +101,36 @@ rm -rf $RPM_BUILD_ROOT
        --optimize=2 \
        --root=$RPM_BUILD_ROOT
 
+%{__python} -- setup.py \
+       build -b build-2 \
+       install \
+       --root=$RPM_BUILD_ROOT \
+       --optimize=2
+
+%if %{with python2}
+%{__python} setup.py \
+       build --build-base build-2 \
+       install \
+       --root=$RPM_BUILD_ROOT \
+       --optimize=2
+
+%py_postclean
+%endif
+
+%{__python3} -- setup.py \
+       build -b build-3 \
+       install \
+       --root=$RPM_BUILD_ROOT \
+       --optimize=2
+
+%if %{with python3}
+%{__python3} setup.py \
+       build --build-base build-3 \
+       install \
+       --root=$RPM_BUILD_ROOT \
+       --optimize=2
+%endif
+
 install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
 
@@ -71,3 +152,25 @@ rm -rf $RPM_BUILD_ROOT
 %{py_sitedir}/TEMPLATE-*.egg-info
 %endif
 %{_examplesdir}/%{name}-%{version}
+
+%if %{with python2}
+%files
+%defattr(644,root,root,755)
+%doc AUTHORS CHANGES LICENSE
+%{py_sitescriptdir}/%{module}
+%{py_sitescriptdir}/%{module}-%{version}-py*.egg-info
+%endif
+
+%if %{with python3}
+%files -n python3-%{module}
+%defattr(644,root,root,755)
+%doc AUTHORS CHANGES LICENSE
+%{py3_sitescriptdir}/%{module}
+%{py3_sitescriptdir}/%{module}-%{version}-py*.egg-info
+%endif
+
+%if %{with doc}
+%files apidoc
+%defattr(644,root,root,755)
+%doc docs/_build/html/*
+%endif
This page took 0.48434 seconds and 4 git commands to generate.