File python-pycparser.spec of Package python-pycparser-rhel

%define realname pycparser
%define srcext   tar.bz2

%if ! 0%{?py_ver:1}
%define py_ver %(python -c "import sys; v=sys.version_info[:2]; print '%%d.%%d'%%v" 2>/dev/null || echo PYTHON-NOT-FOUND)
%endif

# Common info
Name:          python-%{realname}
Version:       2.17
Release:       wiz%{?extraver:0.}1%{?dist}
License:       BSD-3-Clause
Group:         Development/Languages/Python
URL:           https://github.com/eliben/pycparser
Summary:       Complete C99 parser in pure Python

# Install-time parameters
Requires:      python%{?suse_version:-base}

# Build-time parameters
%if ! 0%{?sles_version}
BuildArch:     noarch
%endif
BuildRequires: python%{?suse_version:-base}
BuildRequires: python-setuptools
BuildRoot:     %{_tmppath}/%{name}-root
Source:        %{realname}-%{version}%{?extraver}.%{srcext}

%description
pycparser is a complete parser of the C language, written in pure Python using
the PLY parsing library. It parses C code into an AST and can serve as
a front-end for C compilers or analysis tools.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{version}%{?extraver}

%build
python setup.py build

%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot} -O2
[ "%{buildroot}" != "/" ] && find %{buildroot}%{python_sitelib}/%{realname}/ -name "*.pyo" -delete

%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

%files
%defattr(-,root,root)
%doc CHANGES LICENSE README.rst
%{python_sitelib}/%{realname}/
%{python_sitelib}/%{realname}-%{version}-py%{py_ver}.egg-info/

%changelog
openSUSE Build Service is sponsored by