From 7b86ef9335fd9120fb7ddcc527b5541417d7325a Mon Sep 17 00:00:00 2001 From: Pete Walter Date: Tue, 10 Apr 2018 12:34:41 +0100 Subject: [PATCH] Conditionally add back Python 2 subpackage on Fedora Dropping it caused dependency issues in other packages. https://bugzilla.redhat.com/show_bug.cgi?id=1559099 --- langtable.spec | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/langtable.spec b/langtable.spec index 98e693f..56c2571 100644 --- a/langtable.spec +++ b/langtable.spec @@ -1,6 +1,10 @@ +%if 0%{?fedora} +%global with_python2 1 +%endif + Name: langtable Version: 0.0.38 -Release: 4%{?dist} +Release: 5%{?dist} Summary: Guessing reasonable defaults for locale, keyboard layout, territory, and language. Group: Development/Tools # the translations in languages.xml and territories.xml are (mostly) @@ -12,6 +16,9 @@ URL: https://github.com/mike-fabian/langtable Source0: https://github.com/mike-fabian/langtable/releases/download/%{version}/%{name}-%{version}.tar.gz BuildArch: noarch BuildRequires: perl-interpreter +%if 0%{?with_python2} +BuildRequires: python2-devel +%endif BuildRequires: python3-devel %description @@ -21,6 +28,23 @@ example, guess the territory and the keyboard layout if the language is known or guess the language and keyboard layout if the territory is already known. +%if 0%{?with_python2} +%package -n python2-langtable +%{?python_provide:%python_provide python2-langtable} +# Remove before F30 +Provides: %{name}-python%{?_isa} = %{version}-%{release} +Obsoletes: %{name}-python < %{version}-%{release} +Summary: Python module to query the langtable-data +Group: Development/Tools +License: GPLv3+ +Requires: %{name} = %{version}-%{release} +Requires: %{name}-data = %{version}-%{release} + +%description -n python2-langtable +This package contains a Python module to query the data +from langtable-data. +%endif + %package python3 Summary: Python module to query the langtable-data Group: Development/Tools @@ -46,14 +70,28 @@ This package contains the data files for langtable. %build perl -pi -e "s,_datadir = '(.*)',_datadir = '%{_datadir}/langtable'," langtable.py +%if 0%{?with_python2} +%py2_build +%endif %py3_build %install +%if 0%{?with_python2} +%py2_install -- --install-data=%{_datadir}/langtable +gzip --force --best $RPM_BUILD_ROOT/%{_datadir}/langtable/*.xml +%endif + %py3_install -- --install-data=%{_datadir}/langtable +# the .xml files copied by the “python3 setup.py install” are identical +# to those copied in the “python2 setup.py install”, +# it does not hurt to gzip them again: gzip --force --best $RPM_BUILD_ROOT/%{_datadir}/langtable/*.xml %check +%if 0%{?with_python2} +(cd $RPM_BUILD_DIR/%{name}-%{version}/data; PYTHONPATH=.. %{__python2} ../test_cases.py; %{__python2} ../langtable.py) +%endif (cd $RPM_BUILD_DIR/%{name}-%{version}/data; LC_CTYPE=en_US.UTF-8 PYTHONPATH=.. %{__python3} ../test_cases.py; %{__python3} ../langtable.py) xmllint --noout --relaxng $RPM_BUILD_ROOT/%{_datadir}/langtable/schemas/keyboards.rng $RPM_BUILD_ROOT/%{_datadir}/langtable/keyboards.xml.gz xmllint --noout --relaxng $RPM_BUILD_ROOT/%{_datadir}/langtable/schemas/languages.rng $RPM_BUILD_ROOT/%{_datadir}/langtable/languages.xml.gz @@ -67,6 +105,11 @@ xmllint --noout --relaxng $RPM_BUILD_ROOT/%{_datadir}/langtable/schemas/timezone %dir %{_datadir}/langtable/ %{_datadir}/langtable/schemas +%if 0%{?with_python2} +%files -n python2-langtable +%{python_sitelib}/* +%endif + %files python3 %{python3_sitelib}/langtable.py %{python3_sitelib}/langtable-*.egg-info @@ -77,6 +120,10 @@ xmllint --noout --relaxng $RPM_BUILD_ROOT/%{_datadir}/langtable/schemas/timezone %{_datadir}/langtable/*.xml.gz %changelog +* Tue Apr 10 2018 Pete Walter - 0.0.38-5 +- Conditionally add back Python 2 subpackage on Fedora +- Resolves: rhbz#1559099 + * Wed Apr 04 2018 Mike FABIAN - 0.0.38-4 - Drop Python 2 subpackage - Resolves: rhbz#1559099