Blob Blame History Raw
%if 0%{?rhel} && 0%{?rhel} <= 6
%{!?__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

%if 0%{?fedora}
%global with_python3 1
%endif

Name:           pycmd
Version:        1.2
Release:        1%{?dist}
Summary:        Tools for managing/searching Python related files
Group:          Development/Languages
License:        MIT
URL:            http://pypi.python.org/pypi/pycmd
Source0:        http://pypi.python.org/packages/source/p/%{name}/%{name}-%{version}.tar.gz
BuildArch:      noarch
BuildRequires:  python2-devel
BuildRequires:  python-setuptools
Requires:       python-setuptools
BuildRequires:  python-py >= 1.4.0
Requires:       python-py >= 1.4.0
%if 0%{?with_python3}
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
BuildRequires:  python3-py >= 1.4.0
%endif # with_python3
# pycmd was separated from pylib at that point
Conflicts:      python-py < 1.4.0


%description
Pycmd is a collection of command line tools for helping with Python
development.

%if 0%{?with_python3}
%package -n python3-pycmd
Summary:        Tools for managing/searching Python related files
Group:          Development/Languages
Requires:       python3-setuptools
Requires:       python3-py >= 1.4.0


%description -n python3-pycmd
Pycmd is a collection of command line tools for helping with Python
development.
%endif # with_python3


%prep
%setup -q
%setup -qc -n %{name}-%{version}
mv %{name}-%{version} python2

%if 0%{?with_python3}
cp -a python2 python3
%endif # with_python3


%build
pushd python2
%{__python2} setup.py build
popd

%if 0%{?with_python3}
pushd python3
%{__python3} setup.py build
popd
%endif # with_python3


%install
pushd python2
%{__python2} setup.py install -O1 --skip-build --root %{buildroot}
popd

# remove shebangs
find %{buildroot}%{python2_sitelib} -name '*.py' \
     -exec sed -i -e '1{/^#!/d}' {} \;

# rename binaries
pushd %{buildroot}%{_bindir}
for cmd in py.cleanup py.convert_unittest py.countloc py.lookup py.svnwcrevert py.which; do
  mv ${cmd} ${cmd}-%{python2_version}
done
popd

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

# remove shebangs from all scripts
find %{buildroot}%{python3_sitelib} -name '*.py' \
     -exec sed -i -e '1{/^#!/d}' {} \;

# rename binaries
pushd %{buildroot}%{_bindir}
for cmd in py.cleanup py.convert_unittest py.countloc py.lookup py.svnwcrevert py.which; do
  mv ${cmd} ${cmd}-%{python3_version}
done
popd
%endif # with_python3

# 2.X binaries are called by default for now
pushd %{buildroot}%{_bindir}
for cmd in py.cleanup py.convert_unittest py.countloc py.lookup py.svnwcrevert py.which; do
  ln -s ${cmd}-%{python2_version} ${cmd}
done
popd


%files
%doc python2/README.txt
%doc python2/CHANGELOG
%license python2/LICENSE
%{_bindir}/py.cleanup
%{_bindir}/py.cleanup-%{python2_version}
%{_bindir}/py.convert_unittest
%{_bindir}/py.convert_unittest-%{python2_version}
%{_bindir}/py.countloc
%{_bindir}/py.countloc-%{python2_version}
%{_bindir}/py.lookup
%{_bindir}/py.lookup-%{python2_version}
%{_bindir}/py.svnwcrevert
%{_bindir}/py.svnwcrevert-%{python2_version}
%{_bindir}/py.which
%{_bindir}/py.which-%{python2_version}
%{python2_sitelib}/*


%if 0%{?with_python3}
%files -n python3-pycmd
%doc python3/README.txt
%doc python3/CHANGELOG
%license python3/LICENSE
%{_bindir}/py.cleanup-%{python3_version}
%{_bindir}/py.convert_unittest-%{python3_version}
%{_bindir}/py.countloc-%{python3_version}
%{_bindir}/py.lookup-%{python3_version}
%{_bindir}/py.svnwcrevert-%{python3_version}
%{_bindir}/py.which-%{python3_version}
%{python3_sitelib}/*
%endif # with_python3


%changelog
* Thu Apr 23 2015 Thomas Moschny <thomas.moschny@gmx.de> - 1.2-1
- Update to 1.2.

* Mon Apr 20 2015 Thomas Moschny <thomas.moschny@gmx.de> - 1.1-2
- Apply updated Python packaging guidelines.
- Mark LICENSE with %%license.

* Fri Jul 18 2014 Thomas Moschny <thomas.moschny@gmx.de> - 1.1-1
- Update to 1.1.

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Tue May 27 2014 Kalev Lember <kalevlember@gmail.com> - 1.0-11
- Rebuilt for https://fedoraproject.org/wiki/Changes/Python_3.4

* Sat Aug 17 2013 Thomas Moschny <thomas.moschny@gmx.de> - 1.0-10
- Update distribute_setup.py (fixes rhbz#992844).
- Modernize spec file.

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

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

* Sat Aug 04 2012 David Malcolm <dmalcolm@redhat.com> - 1.0-7
- rebuild for https://fedoraproject.org/wiki/Features/Python_3.3

* Sat Jul 21 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Sat Jan 14 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

* Sat Sep  3 2011 Thomas Moschny <thomas.moschny@gmx.de> - 1.0-4
- Fix: python3 dependencies.

* Thu Aug 11 2011 Thomas Moschny <thomas.moschny@gmx.de> - 1.0-3
- Update Requires and BuildRequires tags.

* Tue Jul  5 2011 Thomas Moschny <thomas.moschny@gmx.de> - 1.0-2
- Python3 subpackage.

* Sun Jan 16 2011 Thomas Moschny <thomas.moschny@gmx.de> - 1.0-1
- New package.