Blob Blame History Raw
%if 0%{?fedora} > 12
%global with_python3 1
%else
%{!?python_sitearch: %global python_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%endif

%global upstream_name dockerpty

Name:           python-%{upstream_name}
Version:        0.3.3
Release:        1%{?dist}
Summary:        Python library to use the pseudo-tty of a docker container

Group:          Development/Libraries
License:        ASL 2.0
URL:            https://github.com/d11wtq/%{upstream_name}
Source0:        %{url}/archive/v%{version}.tar.gz#/%{upstream_name}-v%{version}.tar.gz

Requires: python-docker-py python-six
BuildRequires:  python-devel python-setuptools python-virtualenv python-six

%if 0%{?with_python3}
Requires: python3-docker-py python3-six
BuildRequires:  python3-devel python3-setuptools python3-six
# For /usr/bin/2to3
BuildRequires:  python-tools
%endif # if with_python3

BuildArch:      noarch

%description
Provides the functionality needed to operate the pseudo-tty (PTY) allocated to
a docker container, using the Python client

%if 0%{?with_python3}
%package -n python3-%{upstream_name}
Summary:    Python library to use the pseudo-tty of a docker container
Group:      Development/Languages

%description -n python3-%{upstream_name}
Provides the functionality needed to operate the pseudo-tty (PTY) allocated to
a docker container, using the Python client
%endif #if with_python3

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

%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
2to3 --write --nobackups %{py3dir}
%endif # with_python3

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

%if 0%{?with_python3}
pushd %{py3dir}
CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build
popd
%endif # with_python3


%install
rm -rf $RPM_BUILD_ROOT
%{__python2} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT

%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
popd
%endif # with_python3

# no tests provided
%check
virtualenv --system-site-packages -p %{__python2} tests
source tests/bin/activate
pip install pytest>=2.5.2 expects>=0.4
py.test tests/unit

%if 0%{?with_python3}
pushd %{py3dir}
virtualenv --system-site-packages -p %{__python3} tests
source tests/bin/activate
pip install pytest>=2.5.2 expects>=0.4
py.test tests/unit
popd
%endif # with_python3

%files
%doc README.md LICENSE.txt MANIFEST.in
%dir %{python2_sitelib}/dockerpty
%{python2_sitelib}/dockerpty/*
%dir %{python2_sitelib}/dockerpty-*.egg-info
%{python2_sitelib}/dockerpty-*.egg-info/*


%if 0%{?with_python3}
%files -n python3-%{upstream_name}
%doc README.md LICENSE.txt MANIFEST.in
%dir %{python3_sitelib}/dockerpty
%{python3_sitelib}/dockerpty/*
%dir %{python3_sitelib}/dockerpty-*.egg-info
%{python3_sitelib}/dockerpty-*.egg-info/*
%endif # with_python3

%changelog
* Sat Jun 06 2015 Roman Mohr <roman@fenkhuber.at> - 0.3.3-1
- Python3 compatible version (rhbz#1172357)

* Sun Nov 30 2014 Roman Mohr <roman@fenkhuber.at> - 0.3.2-1
- Update to latest upstream
- Enable unit tests

* Fri Aug 22 2014 Adam Miller <maxamillion@fedoraproject.org> - 0.2.3-1
- Update to latest upstream

* Mon Aug 11 2014 Adam Miller <maxamillion@fedoraproject.org> - 0.2.1-4
- Fixed egg-info dir listings, set noarch based on reviewer feedback

* Mon Aug 11 2014 Adam Miller <maxamillion@fedoraproject.org> - 0.2.1-3
- Fixed files section, fixed py3 summary listing

* Fri Aug 08 2014 Adam Miller <maxamillion@fedoraproject.org> - 0.2.1-2
- Fix __python vs __python2 macro usage and  __python3's description
- Set ExclusiveArch because of docker
- Remove clean section, not needed

* Wed Jul 23 2014 Adam Miller <maxamillion@fedoraproject.org> - 0.2.1-1
- Initial package for Fedora