From 0924967211c08f602cb01290463d8f0e388b8cbe Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Sep 23 2016 11:59:07 +0000 Subject: Fix build on older distributions without Python 3 support --- diff --git a/package/modulemd.spec b/package/modulemd.spec index 3785e80..6bd8afc 100644 --- a/package/modulemd.spec +++ b/package/modulemd.spec @@ -1,8 +1,18 @@ %global _pkgdescription A python library for manipulation of the proposed module metadata format. +%if 0%{?fedora} > 21 || 0%{?rhel} > 7 +%global with_python3 1 +%else +%global with_python3 0 +%endif + +%{!?__python2: %global __python2 /usr/bin/python2} +%{!?py2_build: %global py2_build %{expand: CFLAGS="%{optflags}" %{__python2} setup.py %{?py_setup_args} build --executable="%{__python2} -s"}} +%{!?py2_install: %global py2_install %{expand: CFLAGS="%{optflags}" %{__python2} setup.py %{?py_setup_args} install -O1 --skip-build --root %{buildroot}}} + Name: modulemd Version: 0 -Release: 12%{?dist} +Release: 13%{?dist} Summary: Module metadata manipulation library License: MIT URL: https://pagure.io/modulemd @@ -11,9 +21,14 @@ URL: https://pagure.io/modulemd Source0: modulemd.tar BuildArch: noarch BuildRequires: python2-devel -BuildRequires: python3-devel BuildRequires: PyYAML +BuildRequires: python-setuptools + +%if 0%{?with_python3} +BuildRequires: python3-devel BuildRequires: python3-PyYAML +BuildRequires: python3-setuptools +%endif %description %{_pkgdescription} @@ -26,8 +41,9 @@ Provides: python-%{name} = %{version}-%{release} %description -n python2-%{name} %{_pkgdescription} -This is python2 bindings. +These are python2 bindings. +%if 0%{?with_python3} %package -n python3-%{name} Summary: %{summary} Requires: python3-PyYAML @@ -35,7 +51,8 @@ Requires: python3-PyYAML %description -n python3-%{name} %{_pkgdescription} -This is python3 bindings +These are python3 bindings. +%endif %package -n modlint Summary: Tool for checking common errors in modulemd files @@ -51,31 +68,45 @@ modlint is a tool for checking common errors in modulemd files. %build %py2_build + +%if 0%{?with_python3} %py3_build +%endif %install %py2_install + +%if 0%{?with_python3} %py3_install +%endif %check %{__python2} setup.py test + +%if 0%{?with_python3} %{__python3} setup.py test +%endif %files -n python2-%{name} %doc README.rst spec.yaml %license LICENSE %{python2_sitelib}/* +%if 0%{?with_python3} %files -n python3-%{name} %doc README.rst spec.yaml %license LICENSE %{python3_sitelib}/* +%endif %files -n modlint %license LICENSE %{_bindir}/modlint %changelog +* Fri Sep 23 2016 Jan Kaluza - 0-13 +- build without Python 3 support on older distributions that don't have it + * Fri Sep 16 2016 Petr Ĺ abata - 0-12 - Update modlint's runtime dependencies - modlint shouldn't install the README and spec.yaml files