%bcond_without python2 # CPython 2.x module
%bcond_without python3 # CPython 3.x module
+# NOTE: 'module' should match the python import path, not the egg name
%define module template
Summary: -
Summary(pl.UTF-8): -
-# Name must match the python module/package name (as in 'import' statement)
+# Name must match the python module/package name (as on pypi or in 'import' statement)
Name: python-%{module}
Version: _
Release: 0.1
URL: -
BuildRequires: rpm-pythonprov
# for the py_build, py_install macros
-BuildRequires: rpmbuild(macros) >= 1.713
+BuildRequires: rpmbuild(macros) >= 1.714
%if %{with python2}
BuildRequires: python-modules
-#BuildRequires: python-setuptools
+BuildRequires: python-setuptools
%endif
%if %{with python3}
BuildRequires: python3-modules
-#BuildRequires: python3-setuptools
+BuildRequires: python3-setuptools
%endif
# when using /usr/bin/env or other in-place substitutions
#BuildRequires: sed >= 4.0
%if %{with python2}
%py_install
+# when files are installed in other way that standard 'setup.py
+# they need to be (re-)compiled
+# change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
+%py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
+%py_comp $RPM_BUILD_ROOT%{py_sitedir}
+
%py_postclean
%endif
# in case there are examples provided
%if %{with python2}
-install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
-cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
+install -d $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
+cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
+find $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} -name '*.py' \
+ | xargs sed -i '1s|^#!.*python\b|#!%{__python}|'
%endif
%if %{with python3}
install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
%defattr(644,root,root,755)
%doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
%{py_sitescriptdir}/%{module}
-%if "%{py_ver}" > "2.4"
%{py_sitescriptdir}/%{module}-%{version}-py*.egg-info
-%endif
-%{_examplesdir}/%{name}-%{version}
+%{_examplesdir}/python-%{module}-%{version}
%endif
%if %{with python3}