File python-pycparser.spec of Package python-pycparser
# Created by pyp2rpm-3.2.3
%global pypi_name pycparser
%bcond_with tests
%global with_python3 1
Name: python-%{pypi_name}
Version: 2.18
Release: 1%{?dist}
Summary: C parser in Python
License: BSD
URL: https://github.com/eliben/pycparser
Source0: https://pypi.io/packages/source/p/pycparser/pycparser-%{version}.tar.gz
Patch100: pycparser-2.10-ply.patch
BuildRequires: python2-devel
BuildRequires: python2-setuptools
BuildRequires: python2-ply >= 3.6
BuildRequires: dos2unix
%description
pycparser is a complete parser for the C language, written in pure Python.
It is a module designed to be easily integrated into applications that
need to parse C source code.
%package -n python2-%{pypi_name}
Summary: %{summary}
%{?python_provide:%python_provide python2-%{pypi_name}}
Requires: python2-ply >= 3.6
%description -n python2-%{pypi_name}
pycparser is a complete parser for the C language, written in pure Python.
It is a module designed to be easily integrated into applications that
need to parse C source code.
%if 0%{?with_python3}
%package -n python3-pycparser
Summary: C parser and AST generator written in Python
Group: System Environment/Libraries
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-ply >= 3.6
Requires: python3-ply >= 3.6
%{?python_provide:%python_provide python3-pycparser}
%description -n python3-pycparser
pycparser is a complete parser for the C language, written in pure Python.
It is a module designed to be easily integrated into applications that
need to parse C source code.
%endif # if with_python3
%prep
%setup -n %{pypi_name}-%{version}
%patch100 -p1 -F5 -b .ply
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info
# remove embedded copy of ply
rm -rf pycparser/ply
dos2unix LICENSE
%build
%py2_build
pushd build/lib/pycparser
%{__python2} _build_tables.py
popd
%if 0%{?with_python3}
%py3_build
pushd build/lib/pycparser
%{__python3} _build_tables.py
popd
%endif # with_python3
%install
%py2_install
%if 0%{?with_python3}
%py3_install
%endif # with_python3
%if %{with tests}
%check
%{__python2} tests/all_tests.py
%if 0%{?with_python3}
%{__python3} tests/all_tests.py
%endif # with_python3
%endif
%files -n python2-pycparser
%license LICENSE
%doc examples
%{python_sitelib}/pycparser/
%{python_sitelib}/pycparser-*.egg-info
%if 0%{?with_python3}
%files -n python3-pycparser
%license LICENSE
%doc examples
%{python3_sitelib}/pycparser/
%{python3_sitelib}/pycparser-*.egg-info
%endif # with_python3
%changelog
* Fri Dec 22 2017 Yunfei Shi <shiyf2@lenovo.com> - 2.18-1
- Initial package.