%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} %if 0%{?fedora} %global with_python3 1 %{!?python3_version: %global python3_version %(%{__python3} -c "import sys; sys.stdout.write(sys.version[:3])")} %endif # pygments is at 1.1.1 in rhel6 %if 0%{?rhel} == 6 %global skip_tests -pygments %endif %if 0%{?rhel} == 7 %global python3_pkgver 34 %else %global python3_pkgver 3 %endif %global pypi_name troposphere Name: python-%{pypi_name} Version: 2.4.0 Release: 1%{?dist} Summary: troposphere - library to create AWS CloudFormation descriptions License: BSD-2-Clause URL: https://pypi.python.org/pypi/%{pypi_name} Source0: https://pypi.python.org/packages/%{pypi_name}-%{version}.tar.gz BuildArch: noarch BuildRequires: python-devel BuildRequires: python%{python3_pkgver}-devel BuildRequires: python%{python3_pkgver}-setuptools BuildRequires: pytest BuildRequires: libyaml-devel Requires: python-cfn_flip %description The troposphere library allows for easier creation of the AWS CloudFormation JSON by writing Python code to describe the AWS resources. troposphere also includes some basic support for OpenStack resources via Heat. %package -n python%{python3_pkgver}-%{pypi_name} Summary: troposphere - library to create AWS CloudFormation descriptions Requires: python%{python3_pkgver}-cfn_flip %{?python_provide:%python_provide python%{python3_pkgver}-%{pypi_name}} %description -n python%{python3_pkgver}-%{pypi_name} The troposphere library allows for easier creation of the AWS CloudFormation JSON by writing Python code to describe the AWS resources. troposphere also includes some basic support for OpenStack resources via Heat. %prep %setup -qc -n %{pypi_name}-%{version} mv %{pypi_name}-%{version} python-%{pypi_name}-%{version} cp -a python-%{pypi_name}-%{version} python%{python3_pkgver}-%{pypi_name}-%{version} %build pushd python-%{pypi_name}-%{version} %py2_build popd pushd python%{python3_pkgver}-%{pypi_name}-%{version} %py3_build popd %install pushd python-%{pypi_name}-%{version} %py2_install rm -fr %{buildroot}%{python2_sitelib}/tests # remove shebangs and fix permissions find %{buildroot}%{python2_sitelib} \( -name '*.py' -o -name 'py.*' \) \ -exec sed -i '1{/^#!/d}' {} \; \ -exec chmod u=rw,go=r {} \; # rename binary mv %{buildroot}%{_bindir}/cfn{,-%{python2_version}} ln -s cfn-%{python2_version} %{buildroot}%{_bindir}/cfn-2 mv %{buildroot}%{_bindir}/cfn2py{,-%{python2_version}} ln -s cfn2py-%{python2_version} %{buildroot}%{_bindir}/cfn2py-2 popd pushd python%{python3_pkgver}-%{pypi_name}-%{version} %py3_install rm -fr %{buildroot}%{python3_sitelib}/tests # remove shebangs and fix permissions find %{buildroot}%{python3_sitelib} \( -name '*.py' -o -name 'py.*' \) \ -exec sed -i '1{/^#!/d}' {} \; \ -exec chmod u=rw,go=r {} \; # rename binary mv %{buildroot}%{_bindir}/cfn{,-%{python3_version}} ln -s cfn-%{python3_version} %{buildroot}%{_bindir}/cfn-3 mv %{buildroot}%{_bindir}/cfn2py{,-%{python3_version}} ln -s cfn2py-%{python3_version} %{buildroot}%{_bindir}/cfn2py-3 popd # 2.X binary is called by default for now ln -s cfn-%{python2_version} %{buildroot}%{_bindir}/cfn ln -s cfn2py-%{python2_version} %{buildroot}%{_bindir}/cfn2py %check #pushd python-%{pypi_name}-%{version} #%{__python2} setup.py test #popd #pushd python%{python3_pkgver}-%{pypi_name}-%{version} #%{__python3} setup.py test #popd %files %doc python-%{pypi_name}-%{version}/README.rst %license python-%{pypi_name}-%{version}/LICENSE %{python2_sitelib}/%{pypi_name} %{python2_sitelib}/%{pypi_name}-%{version}-py?.?.egg-info %{_bindir}/cfn %{_bindir}/cfn2py %{_bindir}/cfn-2 %{_bindir}/cfn2py-2 %{_bindir}/cfn-%{python2_version} %{_bindir}/cfn2py-%{python2_version} %files -n python%{python3_pkgver}-%{pypi_name} %doc python%{python3_pkgver}-%{pypi_name}-%{version}/README.rst %license python%{python3_pkgver}-%{pypi_name}-%{version}/LICENSE %{python3_sitelib}/%{pypi_name} %{python3_sitelib}/%{pypi_name}-%{version}-py?.?.egg-info %{_bindir}/cfn-3 %{_bindir}/cfn2py-3 %{_bindir}/cfn-%{python3_version} %{_bindir}/cfn2py-%{python3_version} %changelog * Fri Dec 1 2017 Aram Minasyan - 2.1.1-2 - Add dependency python-cfn_flip. * Tue Nov 28 2017 Aram Minasyan - 2.1.1-1 - Initial RPM Package.