]> git.pld-linux.org Git - projects/template-specs.git/blobdiff - python.spec
setuptools is likely to be used
[projects/template-specs.git] / python.spec
index f6eebfdc47140a15d27b734204bff4024553c889..f40beda00f4b0ba113f41c10923a6039112d76f9 100644 (file)
@@ -9,10 +9,11 @@
 %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
@@ -24,14 +25,14 @@ Source0:    https://pypi.python.org/packages/source/M/MODULE/%{module}-%{version}.t
 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
@@ -92,6 +93,12 @@ rm -rf $RPM_BUILD_ROOT
 %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
 
@@ -101,8 +108,10 @@ rm -rf $RPM_BUILD_ROOT
 
 # 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}
@@ -119,10 +128,8 @@ rm -rf $RPM_BUILD_ROOT
 %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}
This page took 0.064046 seconds and 4 git commands to generate.