Conditionalize the python2 subpackage

This commit is contained in:
Charalampos Stratakis 2018-06-12 11:50:25 +02:00 committed by Miro Hrončok
parent 275ef13225
commit bcac51858f

View File

@ -1,11 +1,14 @@
%if 0%{?fedora} > 12
%global with_python3 1
%else
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())")}
%endif
%global pypi_name lesscpy
%if 0%{?rhel} > 7
# Disable python2 build by default
%bcond_with python2
%else
%bcond_without python2
%endif
Name: python-%{pypi_name}
Version: 0.13.0
Release: 2%{?dist}
@ -15,13 +18,15 @@ License: MIT
URL: https://github.com/robotis/lesscpy
Source0: https://pypi.python.org/packages/source/l/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
BuildArch: noarch
%if %{with python2}
BuildRequires: python2-devel
BuildRequires: python2-setuptools
BuildRequires: python2-ply
BuildRequires: python2-nose
BuildRequires: python2-coverage
BuildRequires: python2-flake8
%endif # with python2
%global _description\
A compiler written in python 3 for the lesscss language. For those of us not\
@ -31,12 +36,14 @@ supported (JavaScript evaluation).
%description %_description
%if %{with python2}
%package -n python2-lesscpy
Summary: %summary
Requires: python2-ply
%{?python_provide:%python_provide python2-lesscpy}
%description -n python2-lesscpy %_description
%endif # with python2
%if 0%{?with_python3}
%package -n python3-lesscpy
@ -68,24 +75,29 @@ popd
%endif
%build
%{__python} setup.py build
%if %{with python2}
%py2_build
%endif # with python2
%if 0%{?with_python3}
pushd %{py3dir}
export LANG=en_US.utf8
env
%{__python3} setup.py build
%py3_build
popd
%endif # with_python3
%install
%{__python} setup.py install --skip-build --root %{buildroot}
%if %{with python2}
%py2_install
%if 0%{?with_python3}
rm %{buildroot}/%{_bindir}/lesscpy
pushd %{py3dir}
%{__python3} setup.py install --skip-build --root %{buildroot}
%endif # with python3
%endif # with python2
%if 0%{?with_python3}
pushd %{py3dir}
%py3_install
# link for backwards compatibility. consider removal in Fedora 30+
ln -s ./lesscpy %{buildroot}/%{_bindir}/py3-lesscpy
popd
@ -93,17 +105,22 @@ popd
#%check
#nosetests -v
#%if 0%{?with_python3}
#%%if %{with python2}
#nosetests -v
#%%endif # with python2
#%%if 0%{?with_python3}
#pushd %{py3dir}
#nosetests-3.3 -v
#popd
#%endif # with_python3
#%%endif # with_python3
%if %{with python2}
%files -n python2-lesscpy
%doc LICENSE
%{python_sitelib}/%{pypi_name}
%{python_sitelib}/%{pypi_name}-%{version}-py?.?.egg-info
%{python2_sitelib}/%{pypi_name}
%{python2_sitelib}/%{pypi_name}-%{version}-py?.?.egg-info
%endif # with python2
%if 0%{?with_python3}
%files -n python3-lesscpy
%doc LICENSE
@ -111,6 +128,7 @@ popd
%{python3_sitelib}/%{pypi_name}
%{python3_sitelib}/%{pypi_name}*.egg-info
%endif # with_python3
%{_bindir}/lesscpy