549c1c
%if 0%{?fedora} > 12
549c1c
%global with_python3 1
549c1c
%else
549c1c
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())")}
549c1c
%endif
549c1c
549c1c
Name:           python-pycparser
549c1c
Summary:        C parser and AST generator written in Python
549c1c
Version:        2.14
549c1c
Release:        1%{?dist}
549c1c
License:        BSD
549c1c
Group:          System Environment/Libraries
549c1c
URL:            http://github.com/eliben/pycparser
549c1c
Source0:        http://github.com/eliben/pycparser/archive/release_v%{version}.tar.gz
549c1c
Source1:        pycparser-0.91.1-remove-relative-sys-path.py
549c1c
549c1c
Patch100:       pycparser-2.10-ply.patch
549c1c
# This is Fedora-specific; I don't think we should request upstream to
549c1c
# remove embedded libraries from their distribuution, when we can remove
549c1c
# them during packaging.
549c1c
549c1c
BuildArch:      noarch
549c1c
549c1c
BuildRequires:  python2-devel python-setuptools
549c1c
549c1c
# for unit tests
549c1c
BuildRequires:  dos2unix
549c1c
BuildRequires:  python-ply
549c1c
549c1c
%if 0%{?with_python3}
549c1c
BuildRequires:  python3-devel python3-setuptools
549c1c
# for unit tests
549c1c
BuildRequires:  python3-ply       
549c1c
%endif # if with_python3
549c1c
549c1c
Requires:       python-ply
549c1c
549c1c
%description
549c1c
pycparser is a complete parser for the C language, written in pure Python.
549c1c
It is a module designed to be easily integrated into applications that
549c1c
need to parse C source code.
549c1c
549c1c
%if 0%{?with_python3}
549c1c
%package -n python3-pycparser
549c1c
Summary:        C parser and AST generator written in Python
549c1c
Group:          System Environment/Libraries
549c1c
Requires:       python3-ply
549c1c
549c1c
%description -n python3-pycparser
549c1c
pycparser is a complete parser for the C language, written in pure Python.
549c1c
It is a module designed to be easily integrated into applications that
549c1c
need to parse C source code.
549c1c
%endif # if with_python3
549c1c
549c1c
%prep
549c1c
%setup -q -n pycparser-release_v%{version}
549c1c
%patch100 -p1 -F5 -b .ply
549c1c
549c1c
# remove embedded copy of ply
549c1c
rm -rf pycparser/ply
549c1c
549c1c
# examples
549c1c
%{__python} %{SOURCE1} examples
549c1c
dos2unix LICENSE
549c1c
549c1c
%if 0%{?with_python3}
549c1c
rm -rf %{py3dir}
549c1c
cp -a . %{py3dir}
549c1c
find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!/usr/bin/python|#!%{__python3}|'
549c1c
%endif # with_python3
549c1c
549c1c
%build
549c1c
%{__python} setup.py build
549c1c
pushd build/lib/pycparser
549c1c
%{__python} _build_tables.py
549c1c
popd
549c1c
549c1c
%if 0%{?with_python3}
549c1c
pushd %{py3dir}
549c1c
%{__python3} setup.py build
549c1c
pushd build/lib/pycparser
549c1c
%{__python3} _build_tables.py
549c1c
popd
549c1c
popd
549c1c
%endif # with_python3
549c1c
549c1c
%install
549c1c
%{__python} setup.py install --skip-build --root %{buildroot}
549c1c
549c1c
%if 0%{?with_python3}
549c1c
pushd %{py3dir}
549c1c
%{__python3} setup.py install --skip-build --root %{buildroot}
549c1c
popd
549c1c
%endif # with_python3
549c1c
549c1c
%check
549c1c
%{__python} tests/all_tests.py 
549c1c
549c1c
%if 0%{?with_python3}
549c1c
%{__python3} tests/all_tests.py 
549c1c
pushd %{py3dir}
549c1c
popd
549c1c
%endif # with_python3
549c1c
 
549c1c
%files
549c1c
%doc examples LICENSE
549c1c
%{python_sitelib}/pycparser/
549c1c
%{python_sitelib}/pycparser-*.egg-info
549c1c
549c1c
%if 0%{?with_python3}
549c1c
%files -n python3-pycparser
549c1c
%{python3_sitelib}/pycparser/
549c1c
%{python3_sitelib}/pycparser-*.egg-info
549c1c
%endif # with_python3
549c1c
549c1c
%changelog
549c1c
* Tue Jun 09 2015 Nathaniel McCallum <npmccallum@redhat.com> - 2.14-1
549c1c
- Update to 2.14
549c1c
549c1c
* Wed Aug 20 2014 Eric Smith <brouhaha@fedoraproject.org> 2.10-1
549c1c
- Update to latest upstream.
549c1c
549c1c
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.09.1-9
549c1c
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
549c1c
549c1c
* Mon May 12 2014 Bohuslav Kabrda <bkabrda@redhat.com> - 2.09.1-8
549c1c
- Rebuilt for https://fedoraproject.org/wiki/Changes/Python_3.4
549c1c
549c1c
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.09.1-7
549c1c
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
549c1c
549c1c
* Tue Jul 23 2013 Eric Smith <brouhaha@fedoraproject.org> 2.09.1-6
549c1c
- Added Python 3 support.
549c1c
549c1c
* Mon Jul 22 2013 Eric Smith <brouhaha@fedoraproject.org> 2.09.1-5
549c1c
- Renumbered Fedora-specific Patch1 to Patch100
549c1c
- Added new Patch1 to fix table generation when the build system
549c1c
  already has a python-pycparser package installed.
549c1c
- Submitted Patch0 and Patch1 as upstream issues.
549c1c
- Added comments about patches.
549c1c
549c1c
* Sun Jul 21 2013 Eric Smith <brouhaha@fedoraproject.org> 2.09.1-4
549c1c
- Upstream repository is now on github.
549c1c
- Fix rpmlint strange-permission complaint.
549c1c
- Rename patches, Source1 to all start with pycparser-{version}, to
549c1c
  simplify updating patches for future upstream releases.
549c1c
549c1c
* Sun Jul 21 2013 Eric Smith <brouhaha@fedoraproject.org> 2.09.1-3
549c1c
- Run _build_tables.py to build the lextab.py and yacctab.py; otherwise
549c1c
  they have to be regenerated at runtime for no benefit.
549c1c
549c1c
* Tue Mar 19 2013 Jos de Kloe <josdekloe@gmail.com> 2.09.1-2
549c1c
- remove the embedded ply code
549c1c
549c1c
* Fri Jan 18 2013 Scott Tsai <scottt.tw@gmail.com> 2.09.1-1
549c1c
- upstream 2.09.1