43773f
%if 0%{?fedora} > 12
43773f
%global with_python3 1
43773f
%else
43773f
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())")}
43773f
%endif
43773f
43773f
Name:             python-ply
43773f
Summary:          Python Lex-Yacc
43773f
Version:          3.4
43773f
Release:          11%{?dist}
43773f
License:          BSD
43773f
Group:            System Environment/Libraries
43773f
URL:              http://www.dabeaz.com/ply/
43773f
Source0:          http://www.dabeaz.com/ply/ply-%{version}.tar.gz
43773f
Patch0:           0001-Replace-md5-in-signature-calculation.patch
43773f
BuildRoot:        %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
43773f
BuildArch:        noarch
43773f
BuildRequires:    python-devel
43773f
43773f
%if 0%{?with_python3}
43773f
BuildRequires:          /usr/bin/2to3
43773f
BuildRequires:          python3-devel
43773f
%endif # if with_python3
43773f
43773f
%description
43773f
PLY is a straightforward lex/yacc implementation. Here is a list of its
43773f
essential features:
43773f
* It is implemented entirely in Python.
43773f
* It uses LR-parsing which is reasonably efficient and well suited for larger
43773f
  grammars.
43773f
* PLY provides most of the standard lex/yacc features including support
43773f
  for empty productions, precedence rules, error recovery, and support
43773f
  for ambiguous grammars.
43773f
* PLY is straightforward to use and provides very extensive error checking.
43773f
* PLY doesn't try to do anything more or less than provide the basic lex/yacc
43773f
  functionality. In other words, it's not a large parsing framework or a
43773f
  component of some larger system.
43773f
43773f
%if 0%{?with_python3}
43773f
%package -n python3-ply
43773f
Summary:        Python Lex-Yacc
43773f
Group:          System Environment/Libraries
43773f
Requires:       python3-setuptools
43773f
43773f
%description -n python3-ply
43773f
PLY is a straightforward lex/yacc implementation. Here is a list of its
43773f
essential features:
43773f
* It is implemented entirely in Python.
43773f
* It uses LR-parsing which is reasonably efficient and well suited for larger
43773f
  grammars.
43773f
* PLY provides most of the standard lex/yacc features including support
43773f
  for empty productions, precedence rules, error recovery, and support
43773f
  for ambiguous grammars.
43773f
* PLY is straightforward to use and provides very extensive error checking.
43773f
* PLY doesn't try to do anything more or less than provide the basic lex/yacc
43773f
  functionality. In other words, it's not a large parsing framework or a
43773f
  component of some larger system.
43773f
%endif # with_python3
43773f
43773f
%prep
43773f
%setup -q -n ply-%{version}
43773f
%patch0 -p0
43773f
sed -i 's|/usr/local/bin/python|/usr/bin/python|g' example/yply/yply.py
43773f
chmod -x example/yply/yply.py example/newclasscalc/calc.py example/classcalc/calc.py example/cleanup.sh
43773f
43773f
%if 0%{?with_python3}
43773f
rm -rf %{py3dir}
43773f
cp -a . %{py3dir}
43773f
find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!/usr/bin/python|#!%{__python3}|'
43773f
43773f
# The README states: "You should not convert PLY using
43773f
# 2to3--it is not necessary and may in fact break the implementation."
43773f
#
43773f
# However, one of the example files contains python 2 "print" syntax, which
43773f
# lead to syntax errors during byte-compilation
43773f
#
43773f
# So we fix this file with 2to3:
43773f
pushd %{py3dir}
43773f
  2to3 --write --nobackups ply/cpp.py
43773f
popd
43773f
%endif # with_python3
43773f
43773f
%build
43773f
%{__python} setup.py build
43773f
43773f
%if 0%{?with_python3}
43773f
pushd %{py3dir}
43773f
%{__python3} setup.py build
43773f
popd
43773f
%endif # with_python3
43773f
43773f
%install
43773f
rm -rf $RPM_BUILD_ROOT
43773f
%{__python} setup.py install --skip-build --root $RPM_BUILD_ROOT
43773f
43773f
%if 0%{?with_python3}
43773f
pushd %{py3dir}
43773f
%{__python3} setup.py install --skip-build --root $RPM_BUILD_ROOT
43773f
popd
43773f
%endif # with_python3
43773f
43773f
%clean
43773f
rm -rf $RPM_BUILD_ROOT
43773f
43773f
%files
43773f
%defattr(-,root,root,-)
43773f
%doc CHANGES README example/
43773f
%{python_sitelib}/ply/
43773f
%{python_sitelib}/ply*.egg-info
43773f
43773f
%if 0%{?with_python3}
43773f
%files -n python3-ply
43773f
%defattr(-,root,root,-)
43773f
%doc CHANGES README example/
43773f
%{python3_sitelib}/ply/
43773f
%{python3_sitelib}/ply*.egg-info
43773f
%endif # with_python3
43773f
43773f
%changelog
43773f
* Tue Mar 7 2017 Stanislav Laznicka <slaznick@redhat.com> 3.4-11
43773f
- Replace md5 in signature calculation in order to allow use in FIPS
43773f
43773f
* Fri Jun 12 2015 Martin Kosek <mkosek@redhat.com> 3.4-10
43773f
- Increase Release number to get a clean upgrade path from EPEL 7
43773f
43773f
* Mon Sep 8 2014 Petr Vobornik <pvoborni@redhat.com> 3.4-1
43773f
- Initial package for RHEL 7