878b4d
%if 0%{?fedora} || 0%{?rhel} >= 8
878b4d
%global with_python3 1
878b4d
%endif
878b4d
878b4d
%if 0%{?rhel} > 7
878b4d
# Disable python2 build by default
878b4d
%bcond_with python2
878b4d
%else
878b4d
%bcond_without python2
878b4d
%endif
878b4d
878b4d
Name:           python-pycparser
878b4d
Summary:        C parser and AST generator written in Python
878b4d
Version:        2.14
878b4d
Release:        14%{?dist}
878b4d
License:        BSD
878b4d
Group:          System Environment/Libraries
878b4d
URL:            http://github.com/eliben/pycparser
878b4d
Source0:        http://github.com/eliben/pycparser/archive/release_v%{version}.tar.gz
878b4d
Source1:        pycparser-0.91.1-remove-relative-sys-path.py
878b4d
878b4d
Patch100:       pycparser-2.10-ply.patch
878b4d
# This is Fedora-specific; I don't think we should request upstream to
878b4d
# remove embedded libraries from their distribuution, when we can remove
878b4d
# them during packaging.
878b4d
878b4d
BuildArch:      noarch
878b4d
878b4d
%if %{with python2}
878b4d
BuildRequires:  python2-devel python2-setuptools
878b4d
878b4d
# for unit tests
878b4d
BuildRequires:  python2-ply >= 3.6
878b4d
%endif # with python2
878b4d
878b4d
BuildRequires:  dos2unix
878b4d
878b4d
%if 0%{?with_python3}
878b4d
BuildRequires:  python3-devel python3-setuptools
878b4d
# for unit tests
878b4d
BuildRequires:  python3-ply       
878b4d
%endif # if with_python3
878b4d
878b4d
%description
878b4d
pycparser is a complete parser for the C language, written in pure Python.
878b4d
It is a module designed to be easily integrated into applications that
878b4d
need to parse C source code.
878b4d
878b4d
%if %{with python2}
878b4d
%package -n python2-pycparser
878b4d
Summary:        C parser and AST generator written in Python
878b4d
Group:          System Environment/Libraries
878b4d
Requires:       python2-ply >= 3.6
878b4d
%{?python_provide:%python_provide python2-pycparser}
878b4d
878b4d
%description -n python2-pycparser
878b4d
pycparser is a complete parser for the C language, written in pure Python.
878b4d
It is a module designed to be easily integrated into applications that
878b4d
need to parse C source code.
878b4d
%endif # with python2
878b4d
878b4d
%if 0%{?with_python3}
878b4d
%package -n python3-pycparser
878b4d
Summary:        C parser and AST generator written in Python
878b4d
Group:          System Environment/Libraries
878b4d
Requires:       python3-ply
878b4d
%{?python_provide:%python_provide python3-pycparser}
878b4d
878b4d
%description -n python3-pycparser
878b4d
pycparser is a complete parser for the C language, written in pure Python.
878b4d
It is a module designed to be easily integrated into applications that
878b4d
need to parse C source code.
878b4d
%endif # if with_python3
878b4d
878b4d
%prep
878b4d
%setup -q -n pycparser-release_v%{version}
878b4d
%patch100 -p1 -F5 -b .ply
878b4d
878b4d
# remove embedded copy of ply
878b4d
rm -rf pycparser/ply
878b4d
878b4d
# examples
878b4d
%if 0%{?with_python3}
878b4d
%{__python3} %{SOURCE1} examples
878b4d
%else
878b4d
%{__python2} %{SOURCE1} examples
878b4d
%endif
878b4d
dos2unix LICENSE
878b4d
878b4d
%build
878b4d
%if %{with python2}
878b4d
%py2_build
878b4d
pushd build/lib/pycparser
878b4d
%{__python2} _build_tables.py
878b4d
popd
878b4d
%endif # with python2
878b4d
878b4d
%if 0%{?with_python3}
878b4d
%py3_build
878b4d
pushd build/lib/pycparser
878b4d
%{__python3} _build_tables.py
878b4d
popd
878b4d
%endif # with_python3
878b4d
878b4d
%install
878b4d
%if %{with python2}
878b4d
%py2_install
878b4d
%endif # with python2
878b4d
878b4d
%if 0%{?with_python3}
878b4d
%py3_install
878b4d
%endif # with_python3
878b4d
878b4d
%check
878b4d
%if %{with python2}
878b4d
%{__python2} tests/all_tests.py
878b4d
%endif # with python2
878b4d
878b4d
%if 0%{?with_python3}
878b4d
%{__python3} tests/all_tests.py
878b4d
%endif # with_python3
878b4d
 
878b4d
 %if %{with python2}
878b4d
%files -n python2-pycparser
878b4d
%license LICENSE
878b4d
%doc examples
878b4d
%{python2_sitelib}/pycparser/
878b4d
%{python2_sitelib}/pycparser-*.egg-info
878b4d
%endif # with python2
878b4d
878b4d
%if 0%{?with_python3}
878b4d
%files -n python3-pycparser
878b4d
%license LICENSE
878b4d
%doc examples
878b4d
%{python3_sitelib}/pycparser/
878b4d
%{python3_sitelib}/pycparser-*.egg-info
878b4d
%endif # with_python3
878b4d
878b4d
%changelog
878b4d
* Sun Jun 10 2018 Charalampos Stratakis <cstratak@redhat.com> - 2.14-14
878b4d
- Conditionalize the python2 subpackage
878b4d
878b4d
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.14-13
878b4d
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
878b4d
878b4d
* Wed Sep 27 2017 Troy Dawson <tdawson@redhat.com> - 2.14-12
878b4d
- Cleanup spec file conditionals
878b4d
878b4d
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.14-11
878b4d
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
878b4d
878b4d
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.14-10
878b4d
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
878b4d
878b4d
* Fri Jan 6 2017 Orion Poplawski <orion@cora.nwra.com> - 2.14-9
878b4d
- Ship python2-pycparser
878b4d
- Modernize spec
878b4d
878b4d
* Fri Dec 09 2016 Charalampos Stratakis <cstratak@redhat.com> - 2.14-8
878b4d
- Rebuild for Python 3.6
878b4d
878b4d
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.14-7
878b4d
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
878b4d
878b4d
* Fri Jul  8 2016 Tom Callaway <spot@fedoraproject.org> - 2.14-6
878b4d
- rebuild to update yacctab.py
878b4d
878b4d
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 2.14-5
878b4d
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
878b4d
878b4d
* Tue Oct 13 2015 Robert Kuska <rkuska@redhat.com> - 2.14-4
878b4d
- Rebuilt for Python3.5 rebuild
878b4d
878b4d
* Tue Jul 14 2015 Stephen Gallagher <sgallagh@redhat.com> - 2.14-3
878b4d
- Rebuild alongside python-ply 3.6
878b4d
878b4d
* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.14-2
878b4d
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
878b4d
878b4d
* Tue Jun 09 2015 Nathaniel McCallum <npmccallum@redhat.com> - 2.14-1
878b4d
- Update to 2.14
878b4d
878b4d
* Wed Aug 20 2014 Eric Smith <brouhaha@fedoraproject.org> 2.10-1
878b4d
- Update to latest upstream.
878b4d
878b4d
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.09.1-9
878b4d
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
878b4d
878b4d
* Mon May 12 2014 Bohuslav Kabrda <bkabrda@redhat.com> - 2.09.1-8
878b4d
- Rebuilt for https://fedoraproject.org/wiki/Changes/Python_3.4
878b4d
878b4d
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.09.1-7
878b4d
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
878b4d
878b4d
* Tue Jul 23 2013 Eric Smith <brouhaha@fedoraproject.org> 2.09.1-6
878b4d
- Added Python 3 support.
878b4d
878b4d
* Mon Jul 22 2013 Eric Smith <brouhaha@fedoraproject.org> 2.09.1-5
878b4d
- Renumbered Fedora-specific Patch1 to Patch100
878b4d
- Added new Patch1 to fix table generation when the build system
878b4d
  already has a python-pycparser package installed.
878b4d
- Submitted Patch0 and Patch1 as upstream issues.
878b4d
- Added comments about patches.
878b4d
878b4d
* Sun Jul 21 2013 Eric Smith <brouhaha@fedoraproject.org> 2.09.1-4
878b4d
- Upstream repository is now on github.
878b4d
- Fix rpmlint strange-permission complaint.
878b4d
- Rename patches, Source1 to all start with pycparser-{version}, to
878b4d
  simplify updating patches for future upstream releases.
878b4d
878b4d
* Sun Jul 21 2013 Eric Smith <brouhaha@fedoraproject.org> 2.09.1-3
878b4d
- Run _build_tables.py to build the lextab.py and yacctab.py; otherwise
878b4d
  they have to be regenerated at runtime for no benefit.
878b4d
878b4d
* Tue Mar 19 2013 Jos de Kloe <josdekloe@gmail.com> 2.09.1-2
878b4d
- remove the embedded ply code
878b4d
878b4d
* Fri Jan 18 2013 Scott Tsai <scottt.tw@gmail.com> 2.09.1-1
878b4d
- upstream 2.09.1