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

%global commit bc345392596d71177afbc16d0d10b8cb572cd901
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%global realname rospkg

Name:           python-%{realname}
Version:        1.0.33
Release:        1%{?dist}
Summary:        Utilities for ROS package, stack, and distribution information

License:        BSD
URL:            http://ros.org/wiki/rospkg
Source0:        https://github.com/ros-infrastructure/%{realname}/archive/%{commit}/%{realname}-%{version}-%{shortcommit}.tar.gz

BuildArch:      noarch

BuildRequires:  python2-devel
BuildRequires:  python-argparse
BuildRequires:  python-setuptools
BuildRequires:  python-catkin-sphinx
%if 0%{?rhel} && 0%{?rhel} < 7
BuildRequires:  python-sphinx10
BuildRequires:  python-nose1.1
%else
BuildRequires:  python-sphinx
BuildRequires:  python-nose
%endif
BuildRequires:  PyYAML
BuildRequires:  python-mock
BuildRequires:  python-coverage

Requires:       PyYAML
Requires:       python-argparse

%if 0%{?with_python3}
%package -n python3-%{realname}
Summary:        Utilities for ROS package, stack, and distribution information

BuildRequires:  python3-coverage
BuildRequires:  python3-devel
BuildRequires:  python3-mock
BuildRequires:  python3-nose
BuildRequires:  python3-PyYAML
BuildRequires:  python3-setuptools
BuildRequires:  python3-sphinx
Requires:       python3-PyYAML
%endif

%description
The ROS packaging system simplifies development and distribution of code
libraries. It enables you to easily specify dependencies between code
libraries, easily interact with those libraries from the command-line, and
release your code for others to use.

%if 0%{?with_python3}
%description -n python3-%{realname}
The ROS packaging system simplifies development and distribution of code
libraries. It enables you to easily specify dependencies between code
libraries, easily interact with those libraries from the command-line, and
release your code for others to use.
%endif

%prep
%setup -qn %{realname}-%{commit}

%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|'
%endif

find -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python2}|'

%build
%{__python2} setup.py build
%if 0%{?rhel} && 0%{?rhel} < 7
make -C doc html man SPHINXBUILD=sphinx-1.0-build
%else
make -C doc html man
%endif
rm -f doc/_build/html/.buildinfo

%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py build
# TODO: Disabled until python3-catkin-sphinx is built
#make -C doc html man SPHINXBUILD=sphinx-build-%{python3_version}
pushd build/scripts-%{python3_version}
for f in *; do mv $f python3-$f; done
popd
popd
%endif

%check
# Tests expect the base folder name to be 'rospkg', so move the source folder
cd ..
mv %{realname}-%{commit} %{realname}
cd %{realname}
# Run the nosetests
%if 0%{?rhel} && 0%{?rhel} < 7
LANG=en_US.utf8 PYTHONPATH=%{buildroot}%{python2_sitelib} nosetests1.1 -w test
%else
LANG=en_US.utf8 PYTHONPATH=%{buildroot}%{python2_sitelib} nosetests -w test
%endif
# Put the source folder back to its original name
cd ..
mv %{realname} %{realname}-%{commit}
cd %{realname}-%{commit}

%if 0%{?with_python3}
# Tests expect the base folder name to be 'rospkg', so move the source folder
cd ..
mv %{py3dir} %{realname}
cd %{realname}
# Run the nosetests
LANG=en_US.utf8 PYTHONPATH=%{buildroot}%{python3_sitelib} nosetests-%{python3_version} -w test
# Put the source folder back to its original name
cd ..
mv %{realname} %{py3dir}
cd %{py3dir}
%endif

%install
rm -rf $RPM_BUILD_ROOT
%{__python2} setup.py install --skip-build --root $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{_datadir}/%{realname}
install -p -m 0644 manifest.xml $RPM_BUILD_ROOT%{_datadir}/%{realname}
mkdir -p $RPM_BUILD_ROOT%{_mandir}/man1
install -p -m 0644 doc/man/rosversion.1 $RPM_BUILD_ROOT%{_mandir}/man1

sed -i 's|#!/usr/bin/env python||' $RPM_BUILD_ROOT%{python_sitelib}/%{realname}/*.py

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

%files
%doc doc/_build/html
%{_bindir}/rosversion
%{python2_sitelib}/%{realname}-%{version}-py?.?.egg-info
%{python2_sitelib}/%{realname}
%{_mandir}/man1/*.gz
%{_datadir}/%{realname}

%if 0%{?with_python3}
%files -n python3-%{realname}
%doc doc/_build/html
%{_bindir}/python3-rosversion
%{python3_sitelib}/%{realname}-%{version}-py?.?.egg-info
%{python3_sitelib}/%{realname}
%endif

%changelog
* Tue Dec 30 2014 Rich Mattes <richmattes@gmail.com> - 1.0.33-1
- Update to release 1.0.33
- Remove upstreamed patch

* Sat Oct 25 2014 Scott K Logan <logans@cottsay.net> - 1.0.31-1
- Update to release 1.0.31
- Fix test failure on PPC
- Remove argparse patch (fixed upstream)
- Fix sphinx and nose dependencies in el6
- Add python3 package

* Tue Jul 15 2014 Scott K Logan <logans@cottsay.net> - 1.0.29-1
- Update to release 1.0.29
- Fix test failure on ARM

* Wed Apr 16 2014 Rich Mattes <richmattes@gmail.com> - 1.0.28-1
- Update to release 1.0.28
- Remove argparse from python dependency list (rhbz#1088448)
- Add requirement on python-argparse
- Add check section
- Add html documentation

* Fri Apr 04 2014 Scott K Logan <logans@cottsay.net> - 1.0.27-1
- Update to release 1.0.27
- Added PyYAML BuildRequires and Requires

* Sat Feb 08 2014 Rich Mattes <richmattes@gmail.com> - 1.0.26-1
- Update to release 1.0.26

* Mon Aug 19 2013 Rich Mattes <richmattes@gmail.com> - 1.0.21-1
- Update to release 1.0.21
- Update to github sourceurl guidelines

* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.20-2.20130318git0a4448e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

* Mon Mar 18 2013 Rich Mattes <richmattes@gmail.com> - 1.0.20-1.20130318git0a4448e
- Update to release 1.0.20

* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.18-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild

* Wed Jan 02 2013 Rich Mattes <richmattes@gmail.com> - 1.0.18-1
- Update to version 1.0.18

* Fri Oct 26 2012 Rich Mattes <richmattes@gmail.com> - 1.0.10-1
- Update to version 1.0.10

* Sat Sep 22 2012 Rich Mattes <richmattes@gmail.com> - 1.0.6-2
- Moved build to build section
- Finer-grained filenames in files section

* Sat Jun 16 2012 Rich Mattes <richmattes@gmail.com> - 1.0.6-1
- Update to version 1.0.6

* Sat Jun 02 2012 Rich Mattes <richmattes@gmail.com> - 1.0.3-1
- Update to version 1.0.3

* Wed Apr 25 2012 Rich Mattes <richmattes@gmail.com> - 1.0.2-1
- Initial package