Blob Blame History Raw
%global modname parse

%if 0%{?rhel} > 7 || 0%{?fedora} >= 12
%bcond_without python3
%else
%bcond_with python3
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from %distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%endif

Name:               python-parse
Version:            1.6.4
Release:            1%{?dist}
Summary:            Opposite of format()

Group:              Development/Libraries
License:            BSD
URL:                http://pypi.python.org/pypi/parse
Source0:            http://pypi.python.org/packages/source/p/%{modname}/%{modname}-%{version}.tar.gz

BuildArch:          noarch
BuildRequires:      python2-devel
BuildRequires:      python-setuptools
%if %{with python3}
BuildRequires:      python3-devel
BuildRequires:      python3-setuptools
%endif


%description
Parse strings using a specification based on the Python format() syntax.

``parse()`` is the opposite of ``format()``

%if %{with python3}
%package -n python3-%{modname}
Summary:        Opposite of format()
Group:          Development/Libraries

%description -n python3-%{modname}
Parse strings using a specification based on the Python format() syntax.

``parse()`` is the opposite of ``format()``

This package works with Python 3.
%endif


%prep
%setup -q -n %{modname}-%{version}

# Remove bundled egg-info in case it exists
rm -rf %{modname}.egg-info

%if %{with python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|'
%endif

%build
%{__python} setup.py build

%if %{with python3}
pushd %{py3dir}
%{__python3} setup.py build
popd
%endif


%install
# Must do the python3 install first because the scripts in /usr/bin are
# overwritten with every setup.py install (and we want the python2
# version to be the default for now).
%if %{with python3}
pushd %{py3dir}
%{__python3} setup.py install --skip-build --root=%{buildroot}
popd
%endif

%{__python} setup.py install -O1 --skip-build --root=%{buildroot}


%check
%{__python} test_parse.py

%if %{with python3}
pushd %{py3dir}
%{__python3} test_parse.py
popd
%endif

%files
%doc README.rst
%{python_sitelib}/%{modname}*

%if %{with python3}
%files -n python3-%{modname}
%doc README.rst
%{python3_sitelib}/%{modname}*
%{python3_sitelib}/__pycache__/%{modname}*
%endif


%changelog
* Thu Jun 19 2014 Matěj Cepl <mcepl@redhat.com> - 1.6.4-1
- New upstream release.

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.6.2-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Wed May 28 2014 Kalev Lember <kalevlember@gmail.com> - 1.6.2-5
- Rebuilt for https://fedoraproject.org/wiki/Changes/Python_3.4

* Tue Aug 27 2013 Matěj Cepl <mcepl@redhat.com> - 1.6.2-4
- There is no official py3k support for RHEL-6.

* Wed Jul 24 2013 Matěj Cepl <mcepl@redhat.com> - 1.6.2-3
- We actually don't need 2to3.

* Wed Jul 24 2013 Matěj Cepl <mcepl@redhat.com> - 1.6.2-2
- make python3 package as well
- BR python-setuptools
- fix changelog

* Tue Jul 23 2013 Matěj Cepl <mcepl@redhat.com> - 1.6.2-1
- initial package for Fedora