File python-Parsley.spec of Package python-Parsley

#
# spec file for package python-Parsley
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2013 LISA GmbH, Bingen, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%define oname   Parsley

Name:           python-Parsley
Version:        1.2
Release:        0
Summary:        Parsing and pattern matching made easy
License:        MIT
Group:          Development/Libraries/Python
Url:            http://github.com/washort/parsley
Source:         https://pypi.python.org/packages/source/P/%{oname}/%{oname}-%{version}.tar.gz
%if 0%{?suse_version}
BuildRequires:  fdupes
%endif
# Documentation requirements:
BuildRequires:  python-Sphinx
# Testing requirements:
BuildRequires:  python-Twisted
BuildRequires:  python-setuptools
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%else
BuildArch:      noarch
%endif

%description
Parsley is a parsing library for people who find parsers scary or annoying. I
wrote it because I wanted to parse a programming language, and tools like PLY
or ANTLR or Bison were very hard to understand and integrate into my Python
code. Most parser generators are based on LL or LR parsing algorithms that
compile to big state machine tables. It was like I had to wake up a different
section of my brain to understand or work on grammar rules.

Parsley, like pyparsing and ZestyParser, uses the PEG algorithm, so each
expression in the grammar rules works like a Python expression. In particular,
alternatives are evaluated in order, unlike table-driven parsers such as yacc,
bison or PLY.

The binaries are prefixed with parsley-.

%package doc
Summary:        Parsing and pattern matching made easy
Group:          Development/Libraries/Python
Requires:       %{name} = %{version}

%description doc
This package contains documentation files for %{name}.

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

%build
python setup.py build
# Generate HTML documentation
pushd doc
make html && rm _build/html/.buildinfo
popd

%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}
mkdir %{buildroot}/%{_bindir}
# rename binaries in order to avoid name clashes with other system packages
for f in {generate_parser,stage}; do
    cp -v bin/$f %{buildroot}/%{_bindir}/parsley-$f
done

%if 0%{?suse_version}
    %fdupes -s %{buildroot}%{_prefix}
%endif

# Correct what fdupes didn't find, because docs are later installed
rm -f doc/_build/html/_downloads/tutorial3-netstrings.py
ln -sf ../_static/listings/tutorial3-netstrings2.py doc/_build/html/_downloads/tutorial3-netstrings2.py
rm -f doc/html/_downloads/tutorial3-netstring-reversal.py
ln -sf ../_static/listings/tutorial3-netstring-reversal.py doc//_build/html/_downloads/tutorial3-netstring-reversal.py

%check
pushd ometa/test
PYTHONPATH='../..' python -m unittest test_builder test_pymeta test_runtime
popd

%files
%defattr(-,root,root)
%doc LICENSE NEWS PKG-INFO README
%{_bindir}/parsley*
%{python_sitelib}/parsley.*
%{python_sitelib}/ometa
%{python_sitelib}/terml
%{python_sitelib}/%{oname}-%{version}-py%{py_ver}.egg-info

%files doc
%defattr(-,root,root)
%doc doc/_build/html examples

%changelog
openSUSE Build Service is sponsored by