Blob Blame History Raw
%global srcname     qutepart
%global sum         Code editor widget

%if 0%{?fedora}
%bcond_without      python3
%endif

%global py3_commit0 0e9612914f0ab90fd62c8160590191bfe4153658
%global py3_date    20151020


Name:           python-%{srcname}
Version:        2.2.2
Release:        5%{?dist}
Summary:        %{sum}

License:        LGPLv2+
URL:            https://github.com/hlamer/%{srcname}

Source0:        %{url}/archive/v%{version}.tar.gz#/%{srcname}-%{version}.tar.gz
# experimental python3 from upstream py3 branch as a subpackage
# https://github.com/hlamer/qutepart/issues/30
Patch0:         %{url}/compare/v%{version}...%{py3_commit0}.patch#/%{srcname}-py3.patch
# AttributeError: type object 'QApplication' has no attribute 'instance'
# https://github.com/hlamer/qutepart/issues/29
Patch1:         %{url}/compare/v%{version}...39dc2a200a11a293611e995429c80c9b0fa545e7.patch#/%{srcname}-docs.patch

BuildRequires:  pcre-devel
Requires:       pcre

BuildRequires:  PyQt4
Requires:       PyQt4

BuildRequires:  python2-devel >= 2.7
BuildRequires:  python-setuptools
BuildRequires:  python-sphinx

%if 0%{with python3}
BuildRequires:  python3-qt5
Requires:       python3-qt5

BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
BuildRequires:  python3-sphinx
%endif

BuildRequires:  xorg-x11-server-Xvfb

%description
Qutepart is a code editor widget for PyQt. Features:
    - Syntax highlighting for 196 languages.
    - Smart indentation for many languages.
    - Line numbers.
    - Bookmarks.
     - Advanced edit operations.
    - Matching braces highlighting.
    - Autocompletion based on document content.
    - Marking too long lines with red line.
    - Rectangular selection and copy-paste.
    - Linter marks support.


%package -n python2-%{srcname}
Summary:        %{sum}
%{?python_provide:%python_provide python2-%{srcname}}

%description -n python2-%{srcname}
Qutepart is a code editor widget for PyQt. Features:
    - Syntax highlighting for 196 languages.
    - Smart indentation for many languages.
    - Line numbers.
    - Bookmarks.
     - Advanced edit operations.
    - Matching braces highlighting.
    - Autocompletion based on document content.
    - Marking too long lines with red line.
    - Rectangular selection and copy-paste.
    - Linter marks support.


%if 0%{with python3}
%package -n python3-%{srcname}
Release:        5.%{py3_date}git%(c=%{py3_commit0}; echo ${c:0:7})%{?dist}
Summary:        %{sum}
%{?python_provide:%python_provide python3-%{srcname}}

%description -n python3-%{srcname}
Qutepart is a code editor widget for PyQt. Features:
    - Syntax highlighting for 196 languages.
    - Smart indentation for many languages.
    - Line numbers.
    - Bookmarks.
     - Advanced edit operations.
    - Matching braces highlighting.
    - Autocompletion based on document content.
    - Marking too long lines with red line.
    - Rectangular selection and copy-paste.
    - Linter marks support.
%endif


%prep
%setup -q -n %{srcname}-%{version}

%if 0%{with python3}
mkdir python3
find -mindepth 1 -maxdepth 1 -not -name python3 |xargs cp -pr -tpython3
pushd python3
%patch0 -p1
# FIXME dirty hacks to prevent gcc errors cause of c-api change in python3
sed -i /ob_type/d %{srcname}/syntax/cParser.c
sed -i -r 's,PyString_AsString\((.*)\).*;,\1;,' %{srcname}/syntax/cParser.c
# disable PyQt5 mocking for sphinx
sed -i -r 's,(MOCK_MODULES = \[).*\],\1],' doc/source/conf.py
# disable sloppy tests
rm tests/test_bookmarks.py tests/test_bracket_hlighter.py tests/test_completion.py tests/test_edit.py
popd
%endif

# python2
%patch1 -p1


%build
# we need CFLAGS for internal gcc call, py2_build sets them
%py2_build
pushd doc
sphinx-build source html
popd

%if 0%{with python3}
pushd python3
%py3_build
pushd doc
sphinx-build-3 source html
popd
popd
%endif

# E: non-standard-executable-perm
find -name \*.so |xargs chmod 0755
# W: hidden-file-or-dir
find -name html -exec rm -r '{}'/.buildinfo '{}'/.doctrees \;


%install
%py2_install

%if 0%{with python3}
pushd python3
%py3_install
%endif


%check
pushd tests
# do some fake X 
xvfb-run %{__python2} run_all.py
popd

%if 0%{with python3}
pushd python3/tests
xvfb-run -a %{__python3} run_all.py
%endif


%files -n python2-%{srcname}
%license LICENSE
%doc README.md ChangeLog todo.txt
%doc doc/html/
%{python2_sitearch}/%{srcname}*


%if 0%{with python3}
%files -n python3-%{srcname}
%license LICENSE
%doc README.md ChangeLog todo.txt
%doc python3/doc/html/
%{python3_sitearch}/%{srcname}*
%endif


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

* Thu Nov 12 2015 Kalev Lember <klember@redhat.com> - 2.2.2-4
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5

* Fri Nov 06 2015 Raphael Groner <projects.rg@smart.ms> - 2.2.2-3
- add subpackages for python versioning
- experimental python3 support

* Mon Oct 19 2015 Raphael Groner <projects.rg@smart.ms> - 2.2.2-2
- take over from Jairo Llopis
- cleanup generally
- use LGPLv2 with "or later"
- add more documentation files
- execute tests
- fix permissions
- use new python macros
- use virtual provides of python2 module

* Fri Aug 28 2015 Jairo Llopis <yajo.sk8@gmail.com> 2.2.2-1
- New upstream version.

* Wed Aug 26 2015 Jairo Llopis <yajo.sk8@gmail.com> 2.2.0-7
- Fix some permissions.
- Remove Spanish descriptions, for easier maintenance.

* Mon May 4 2015 Jairo Llopis <yajo.sk8@gmail.com> 2.2.0-6
- Fix license macro in SPEC.
- Fix a couple of redundancies in SPEC.

* Thu Apr 30 2015 Jairo Llopis <yajo.sk8@gmail.com> 2.2.0-5
- New upstream version.
- Clear SPEC redundancies.
- Force usage of Python 2 macros in SPEC.

* Fri Feb 6 2015 Jairo Llopis <yajo.sk8@gmail.com> 2.1.0-4
- New upstream version.
- Update descriptions and dependencies to match upstream SPEC.
- Remove support for Fedora < 20.

* Mon Jul 7 2014 Jairo Llopis <yajo.sk8@gmail.com> 1.3.0-3
- New upstream version.
- Fix typo.

* Fri Oct 25 2013 Jairo Llopis <yajo.sk8@gmail.com> 1.1.0-2
- Fix comments.
- Fix translation.
- Fix CFLAGS when building.
- Fix license.

* Sun Sep 8 2013 Jairo Llopis <yajo.sk8@gmail.com>  1.1.0-1
- Initial release.