Blob Blame History Raw
%global module rxjson

%if 0%{?fedora}
%global with_python3 1
%else
# EL doesn't have Python 3
%global with_python3 0
%endif

%if 0%{?rhel} || 0%{?rhel} < 7
# EL 6 doesn't have this macro
%global __python2       %{__python}
%global python2_sitelib %{python_sitelib}
%endif

Name:             python-rxjson
Summary:          JSON RX Schema validation tool
Version:          0.2
Release:          7%{?dist}

License:          GPLv2
URL:              https://pypi.python.org/pypi/%{module}
Source0:          https://pypi.python.org/packages/source/r/%{module}/%{module}-%{version}.tar.gz

BuildArch:        noarch

BuildRequires:    python2-devel
BuildRequires:    python-setuptools
BuildRequires:    python-d2to1

%description
JSON RX Schema validation tool.


%if %{with_python3}
%package -n python3-rxjson
Summary:          JSON RX Schema validation tool

BuildRequires:    python3-devel
BuildRequires:    python3-setuptools
BuildRequires:    python3-d2to1

%description -n python3-rxjson
JSON RX Schema validation tool.
%endif


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

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


%build
CFLAGS="$RPM_OPT_FLAGS" %{__python2} setup.py build

%if %{with_python3}
pushd %{py3dir}
# Default encoding is 'ascii' if we don't set a UTF-8 locale, and setup.cfg
# contains some non-ascii characters
LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 \
    CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build
popd
%endif


%install
%if %{with_python3}
pushd %{py3dir}
# Default encoding is 'ascii' if we don't set a UTF-8 locale, and setup.cfg
# contains some non-ascii characters
LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 \
    %{__python3} setup.py install --skip-build --root %{buildroot}
popd
%endif

%{__python2} setup.py install --skip-build --root %{buildroot}


%files
%doc README.rst
%{python2_sitelib}/%{module}*

%if %{with_python3}
%files -n python3-rxjson
%doc README.rst
%{python3_sitelib}/%{module}*
%endif


%changelog
* Mon Dec 19 2016 Miro HronĨok <mhroncok@redhat.com> - 0.2-7
- Rebuild for Python 3.6

* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.2-6
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.2-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Tue Nov 10 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.2-4
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5

* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

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

* Mon Jun 02 2014 Mathieu Bridon <bochecha@fedoraproject.org> - 0.2-1
- Initial package for Fedora.