Blob Blame History Raw
%if 0%{?fedora}
%global with_python3 1
%else
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%endif

%bcond_without python2

%global modname q

Name:           python-%{modname}
Version:        2.6
Release:        11%{?dist}
Summary:        Quick and dirty python debugging output

License:        ASL 2.0
URL:            https://pypi.python.org/pypi/q
Source0:        https://files.pythonhosted.org/packages/source/%(n=%{modname}; echo ${n:0:1})/%{modname}/%{modname}-%{version}.tar.gz
# https://github.com/zestyping/q/pull/28
Patch0001:      0001-Alternate-pprint-for-values.patch
Patch1000:      q-2.6-remove-setuptools-dep.patch

BuildArch:      noarch

%global _description \
If you have ever been frustrated trying to debug with print because a web\
application or a unittesting framework is swallowing your debugging output,\
q will make you jump for joy.\
\
  import q\
  variable = 'Hmmm... something happened here'\
  q.q(variable)\
\
cat /tmp/q

%description %{_description}

%if %{with python2}
%package -n python2-%{modname}
Summary:        %{summary}
%{?python_provide:%python_provide python2-%{modname}}
BuildRequires:  python2-devel

%description -n python2-%{modname} %{_description}

Python 2 version.
%endif

%if %{with_python3}
%package -n python3-%{modname}
Summary:        %{summary}
%{?python_provide:%python_provide python3-%{modname}}
BuildRequires:  python3-devel

%description -n python3-%{modname} %{_description}

Python 3 version.
%endif

%prep
%autosetup -n %{modname}-%{version} -p1

%build

%if %{with python2}
%py2_build
%endif

%if %{with_python3}
%py3_build
%endif

%install
%if %{with python2}
%py2_install
%endif

%if %{with_python3}
%py3_install
%endif

%check
%if %{with python2}
%{__python2} test/test_*.py -v
%endif

%if %{with_python3}
%{__python3} test/test_*.py -v
%endif

%if %{with python2}
%pretrans -p <lua> -n python2-%{modname}
path = "%{python2_sitelib}/%{modname}-%{version}-py%{python2_version}.egg-info"
st = posix.stat(path)
if st and st.type == "directory" then
  status = os.rename(path, path .. ".rpmmoved")
  if not status then
    suffix = 0
    while not status do
      suffix = suffix + 1
      status = os.rename(path .. ".rpmmoved", path .. ".rpmmoved." .. suffix)
    end
    os.rename(path, path .. ".rpmmoved")
  end
end
%endif

%if %{with_python3}
%pretrans -p <lua> -n python3-%{modname}
path = "%{python3_sitelib}/q-2.6-py%{python3_version}.egg-info"
st = posix.stat(path)
if st and st.type == "directory" then
  status = os.rename(path, path .. ".rpmmoved")
  if not status then
    suffix = 0
    while not status do
      suffix = suffix + 1
      status = os.rename(path .. ".rpmmoved", path .. ".rpmmoved." .. suffix)
    end
    os.rename(path, path .. ".rpmmoved")
  end
end
%endif

%if %{with python2}
%files -n python2-%{modname}
%doc README.md
%{python2_sitelib}/%{modname}-*.egg-info
%{python2_sitelib}/%{modname}.py*
%ghost %{python2_sitelib}/%{modname}-*.egg-info.rpmmoved/
%endif

%if %{with_python3}
%files -n python3-%{modname}
%doc README.md
%{python3_sitelib}/%{modname}-*.egg-info
%{python3_sitelib}/%{modname}.py
%{python3_sitelib}/__pycache__/%{modname}.*
%ghost %{python3_sitelib}/%{modname}-*.egg-info.rpmmoved/
%endif

%changelog
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.6-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Tue Sep 18 2018 Toshio Kuratomi <toshio@fedoraproject.org> - - 2.6-10
- Deal with rpm's inability to replace directories with files

* Tue Sep 18 2018 Toshio Kuratomi <toshio@fedoraproject.org> - - 2.6-9
- Remove the setuptools dep as it doesn't add anything to the package and this way
  we wouldn't have to keep setuptools running on the python2 stack.

* Tue Sep 18 2018 Toshio Kuratomi <toshio@fedoraproject.org> - - 2.6-8
- Conditionalize the python2 and python3 builds.  This will allow the Python2
  build to be automatically omitted once Python2 is removed from Fedora and the
  spec file to be shared with EPEL builds.

* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.6-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 2.6-6
- Rebuilt for Python 3.7

* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.6-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.6-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.6-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Mon Dec 19 2016 Miro Hrončok <mhroncok@redhat.com> - 2.6-2
- Rebuild for Python 3.6

* Thu Nov 17 2016 Igor Gnatenko <i.gnatenko.brain@gmail.com> - 2.6-1
- Update to 2.6
- Modernize spec
- Run test suite

* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.5-6
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 2.5-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Tue Nov 10 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.5-4
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5

* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.5-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Fri Dec 12 2014 Toshio Kuratomi <toshio@fedoraproject.org> - 2.5-2
- Add prettyprint of values
- Make the tracing decorator more transparent

* Fri Dec  5 2014 Toshio Kuratomi <toshio@fedoraproject.org> - 2.5-1
- New upstream version

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.4-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Wed May 28 2014 Kalev Lember <kalevlember@gmail.com> - 2.4-3
- Rebuilt for https://fedoraproject.org/wiki/Changes/Python_3.4

* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

* Wed May 22 2013 Toshio Kuratomi <toshio@fedoraproject.org> - 2.4-1
- New upstream with some enhancements from severl people.
- Build with python3 support.

* Thu Apr 11 2013 Toshio Kuratomi <toshio@fedoraproject.org> - 2.3-2
- New upstream release.
- README file from upstream's SCM
- Note patches we have for upstream

* Tue Mar 19 2013 Toshio Kuratomi <toshio@fedoraproject.org> - 1.1-1
- Initial Fedora build