Blob Blame History Raw
%{?!_without_python2:%global with_python2 0%{?_with_python2:1} || !(0%{?fedora} >= 32 || 0%{?rhel} >= 8)}
%{?!_without_python3:%global with_python3 0%{?_with_python3:1} || !0%{?rhel} || 0%{?rhel} >= 7}

%global srcname rospkg

Name:           python-%{srcname}
Version:        1.5.1
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/%{srcname}/archive/%{version}/%{srcname}-%{version}.tar.gz

BuildArch:      noarch

%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.


%package doc
Summary:        Documentation for %{name}
BuildRequires:  make
BuildRequires:  python%{python3_pkgversion}-catkin-sphinx
BuildRequires:  python%{python3_pkgversion}-pytest
BuildRequires:  python%{python3_pkgversion}-sphinx

%description doc
HTML documentation for the '%{srcname}' Python module.


%if 0%{?with_python2}
%package -n python2-%{srcname}
Summary:        %{summary}
BuildRequires:  python2-catkin_pkg
BuildRequires:  python2-devel
BuildRequires:  python2-mock
BuildRequires:  python2-pytest
BuildRequires:  python2-pyyaml
BuildRequires:  python2-setuptools
%{?python_provide:%python_provide python2-%{srcname}}

%if %{undefined __pythondist_requires}
Requires:       python2-catkin_pkg
Requires:       python2-pyyaml
%endif

%if 0%{?fedora} || 0%{?rhel} >= 8
Suggests:       %{name}-doc = %{version}-%{release}
%endif

%description -n python2-%{srcname}
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


%if 0%{?with_python3}
%package -n python%{python3_pkgversion}-%{srcname}
Summary:        %{summary}
BuildRequires:  python%{python3_pkgversion}-catkin_pkg
BuildRequires:  python%{python3_pkgversion}-devel
BuildRequires:  python%{python3_pkgversion}-pytest
BuildRequires:  python%{python3_pkgversion}-PyYAML
BuildRequires:  python%{python3_pkgversion}-setuptools
%{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}}

%if %{undefined __pythondist_requires}
Requires:       python%{python3_pkgversion}-catkin_pkg
Requires:       python%{python3_pkgversion}-PyYAML
%endif

%if 0%{?fedora} || 0%{?rhel} >= 8
Suggests:       %{name}-doc = %{version}-%{release}
%endif

%description -n python%{python3_pkgversion}-%{srcname}
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
%autosetup -p1 -n %{srcname}-%{version}

# Drop unsupported syntax in older setuptools
sed -i "s/mock; python_version < '3.3'//" setup.py

%if !(0%{?with_python2})
find test -type f | xargs sed -i '1{s@^#!/usr/bin/env python@#!%{__python3}@}'
%endif

%if 0%{?rhel} && 0%{?rhel} < 8
# This syntax isn't supported by setuptools in RHEL 7
# The dependency isn't used for Python 3.6 anyway, so just remove it
sed -i "s/\([ \t]*\).*distro >= 1.4.0; python_version >= '3.8'.*/\1pass/" setup.py
%endif


%build
%if 0%{?with_python2}
%py2_build
%endif

%if 0%{?with_python3}
%py3_build
%endif

%make_build -C doc html man SPHINXBUILD=sphinx-build-%{python3_version}
rm doc/_build/html/.buildinfo


%install
%if 0%{?with_python2}
%py2_install
install -p -m0644 -D doc/man/rosversion.1 %{buildroot}%{_mandir}/man1/rosversion.1
%endif

%if 0%{?with_python3}
%py3_install -- --install-scripts %{_bindir}/python3
pushd %{buildroot}%{_bindir}/python3
for i in *; do mv $i ../python3-$i; done
popd
rmdir %{buildroot}%{_bindir}/python3
install -p -m0644 -D doc/man/rosversion.1 %{buildroot}%{_mandir}/man1/python3-rosversion.1
%endif


%check
%if 0%{?rhel}
export LANG=en_US.UTF-8
%endif

%if 0%{?with_python2}
PYTHONPATH=%{buildroot}%{python2_sitelib} \
%if 0%{?fedora}
    LANG=C.UTF-8 \
%endif
    %{__python2} -m pytest test
%endif

%if 0%{?with_python3}
PYTHONPATH=%{buildroot}%{python3_sitelib} \
    %{__python3} -m pytest test
%endif


%files doc
%doc doc/_build/html

%if 0%{?with_python2}
%files -n python2-%{srcname}
%doc README.md
%{python2_sitelib}/%{srcname}/
%{python2_sitelib}/%{srcname}-%{version}-py%{python2_version}.egg-info/
%{_bindir}/rosversion
%{_mandir}/man1/rosversion.1.*
%endif

%if 0%{?with_python3}
%files -n python%{python3_pkgversion}-%{srcname}
%doc README.md
%{python3_sitelib}/%{srcname}/
%{python3_sitelib}/%{srcname}-%{version}-py%{python3_version}.egg-info/
%{_bindir}/python3-rosversion
%{_mandir}/man1/python3-rosversion.1.*
%endif


%changelog
* Fri May 03 2024 Scott K Logan <logans@cottsay.net> - 1.5.1-1
- Update to 1.5.1 (rhbz#2276182)

* Tue May 09 2023 Scott K Logan <logans@cottsay.net> - 1.5.0-1
- Update to 1.5.0 (rhbz#2180332)

* Fri May 27 2022 Scott K Logan <logans@cottsay.net> - 1.4.0-1
- Update to 1.4.0

* Fri Apr 16 2021 Scott K Logan <logans@cottsay.net> - 1.3.0-1
- Update to 1.3.0 (rhbz#1945454)

* Thu Feb 04 2021 Scott K Logan <logans@cottsay.net> - 1.2.10-1
- Update to 1.2.10 (rhbz#1897763)

* Tue Jun 23 2020 Scott K Logan <logans@cottsay.net> - 1.2.8-1
- Update to 1.2.8 (rhbz#1849858)

* Sat May 09 2020 Scott K Logan <logans@cottsay.net> - 1.2.6-1
- Update to 1.2.6 (rhbz#1831400)

* Mon Apr 20 2020 Scott K Logan <logans@cottsay.net> - 1.2.4-2
- Add upstream patch for distro dependency

* Wed Apr 15 2020 Scott K Logan <logans@cottsay.net> - 1.2.4-1
- Update to 1.2.4 (rhbz#1775451)

* Fri Aug 09 2019 Scott K Logan <logans@cottsay.net> - 1.1.10-1
- Update to 1.1.10

* Wed Jul 17 2019 Scott K Logan <logans@cottsay.net> - 1.1.9-1
- Update to 1.1.9 (rhbz#1700773)

* Fri Apr 12 2019 Scott K Logan <logans@cottsay.net> - 1.1.8-1
- Update to 1.1.8 (rhbz#1699085)
- Switch to Python 3 Sphinx
- Create a separate 'doc' package
- Handle automatic dependency generation (f30+)

* Thu Dec 10 2015 Rich Mattes <richmattes@gmail.com> - 1.0.38-2
- Add additional architectures to uname test (rhbz#1290136)

* Tue Oct 20 2015 Rich Mattes <richmattes@gmail.com> - 1.0.38-1
- Update to release 1.0.38 (rhbz#1270086)

* Wed Mar 04 2015 Rich Mattes <richmattes@gmail.com> - 1.0.35-1
- Update to release 1.0.35
- Remove Fedora 12 spec conditionals

* 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

* 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

* 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