From: Jan Rękorajski Date: Fri, 4 Jul 2014 19:44:18 +0000 (+0200) Subject: - new X-Git-Tag: auto/th/python-docopt-0.6.2-1 X-Git-Url: http://git.pld-linux.org/gitweb.cgi?a=commitdiff_plain;h=d0fc539f61fc188815c7d7a4a36f946331353bc6;p=packages%2Fpython-docopt.git - new --- d0fc539f61fc188815c7d7a4a36f946331353bc6 diff --git a/python-docopt.spec b/python-docopt.spec new file mode 100644 index 0000000..bc6e56e --- /dev/null +++ b/python-docopt.spec @@ -0,0 +1,113 @@ +# +# Conditional build: +%bcond_without tests # do not perform "make test" +%bcond_without python2 # CPython 2.x module +%bcond_without python3 # CPython 3.x module + +%define module docopt +Summary: Pythonic argument parser, that will make you smile +Name: python-%{module} +Version: 0.6.2 +Release: 1 +License: MIT +Group: Libraries/Python +Source0: https://pypi.python.org/packages/source/d/docopt/%{module}-%{version}.tar.gz +# Source0-md5: 4bc74561b37fad5d3e7d037f82a4c3b1 +URL: http://docopt.org/ +BuildRequires: rpm-pythonprov +# if py_postclean is used +BuildRequires: rpmbuild(macros) >= 1.219 +# when using /usr/bin/env or other in-place substitutions +#BuildRequires: sed >= 4.0 +%if %{with python2} +BuildRequires: python-distribute +%endif +%if %{with python3} +BuildRequires: python3-distribute +BuildRequires: python3-modules +%endif +Requires: python-modules +BuildArch: noarch +BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) + +%description +docopt creates beautiful command-line interfaces. + +%package -n python3-%{module} +Summary: Pythonic argument parser, that will make you smile +Group: Libraries/Python + +%description -n python3-%{module} +docopt creates beautiful command-line interfaces. + +%prep +%setup -q -n %{module}-%{version} + +# fix #!/usr/bin/env python -> #!/usr/bin/python: +#%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py + +%build +%if %{with python2} +%{__python} setup.py build --build-base build-2 %{?with_tests:test} +%endif + +%if %{with python3} +%{__python3} setup.py build --build-base build-3 %{?with_tests:test} +%endif + +%install +rm -rf $RPM_BUILD_ROOT + +%if %{with python2} +%{__python} setup.py \ + build --build-base build-2 \ + install --skip-build \ + --optimize=2 \ + --root=$RPM_BUILD_ROOT + +%py_postclean +%endif + +%if %{with python3} +%{__python3} setup.py \ + build --build-base build-3 \ + install --skip-build \ + --optimize=2 \ + --root=$RPM_BUILD_ROOT +%endif + +# in case there are examples provided +%if %{with python2} +install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} +cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} +%endif +%if %{with python3} +install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} +cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} +find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \ + | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|' +%endif + +%clean +rm -rf $RPM_BUILD_ROOT + +%if %{with python2} +%files +%defattr(644,root,root,755) +%doc README.rst +%{py_sitescriptdir}/*.py[co] +%if "%{py_ver}" > "2.4" +%{py_sitescriptdir}/%{module}-*.egg-info +%endif +%{_examplesdir}/%{name}-%{version} +%endif + +%if %{with python3} +%files -n python3-%{module} +%defattr(644,root,root,755) +%doc README.rst +%{py3_sitescriptdir}/__pycache__/*.py[co] +%{py3_sitescriptdir}/%{module}.py +%{py3_sitescriptdir}/%{module}-%{version}-py*.egg-info +%{_examplesdir}/python3-%{module}-%{version} +%endif