# Set python3 as default on fedora %if 0%{?fedora} > 12 %global with_python3 1 %endif # Set python2 related macros %if 0%{?rhel} && 0%{?rhel} <= 6 %{!?__python2: %global __python2 /usr/bin/python2} %{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} %{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")} %endif %global pkgname line_profiler Name: python-%{pkgname} Version: 1.0 Release: 4%{?dist} Summary: Line-by-line profiler for python License: BSD URL: https://github.com/rkern/%{pkgname} Source0: https://pypi.python.org/packages/source/l/%{pkgname}/%{pkgname}-%{version}.tar.gz BuildRequires: python2-devel BuildRequires: python-setuptools Requires: python2 Provides: python2-%{pkgname} = %{version}-%{release} %description line_profiler is a module for doing line-by-line profiling of functions. kernprof is a convenient script for running either line_profiler or the Python standard library's cProfile or profile modules, depending on what is available. %if 0%{?with_python3} %package -n python3-%{pkgname} Summary: Line-by-line profiler for python3 BuildRequires: python3-devel BuildRequires: python3-setuptools Requires: python3 %description -n python3-%{pkgname} line_profiler is a module for doing line-by-line profiling of functions. kernprof is a convenient script for running either line_profiler or the Python standard library's cProfile or profile modules, depending on what is available. %endif %prep %setup -q -c %if 0%{?with_python3} # Prepare python3 directory. Do not use py3dir as it is unclean. cp -a %{pkgname}-%{version} python3 find python3 -name '*.py' | xargs sed -i '/^#!\/usr\/bin\/env\ python/d' %endif find %{pkgname}-%{version} -name '*.py' | xargs sed -i '/^#!\/usr\/bin\/env\ python/d' rm -rf *.egg-info %build # Build with python2 pushd %{pkgname}-%{version} CFLAGS="$RPM_OPT_FLAGS" %{__python2} setup.py build popd # Build with python3 %if 0%{?with_python3} pushd python3 CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build popd %endif %install # Install with python2 pushd %{pkgname}-%{version} %{__python2} setup.py install --skip-build --root=%{buildroot} cp %{buildroot}%{_bindir}/kernprof %{buildroot}%{_bindir}/kernprof-%{python2_version} popd # Install with python3 %if 0%{?with_python3} pushd python3 %{__python3} setup.py install --skip-build --root=%{buildroot} cp %{buildroot}%{_bindir}/kernprof %{buildroot}%{_bindir}/kernprof-%{python3_version} popd %endif %files %doc %{pkgname}-%{version}/README.rst %license %{pkgname}-%{version}/LICENSE.txt %{python2_sitearch}/* %ghost %{_bindir}/kernprof %{_bindir}/kernprof-%{python2_version} %if 0%{?with_python3} %files -n python3-%{pkgname} %doc %{pkgname}-%{version}/README.rst %license %{pkgname}-%{version}/LICENSE.txt %{python3_sitearch}/* %{_bindir}/kernprof-%{python3_version} %endif %changelog * Wed Jul 22 2015 Jackson Isaac - 1.0-4 - Rename kernprof binary instead of symlinking. * Mon Jul 20 2015 Jackson Isaac - 1.0-3 - Do not use py3dir as it is unclean. Use chmod instead of attr. * Wed Jul 15 2015 Jackson Isaac - 1.0-2 - Add compiler flags in build. Create py2 and py3 specific packages. - Add kernprof script in buildroot for both py2 and py3 versions. * Wed Jul 8 2015 Jackson Isaac - 1.0-1 - Initial version of line_profiler package