From 4a68c1bf6e23a251eafd43110c8267c7665dc5b4 Mon Sep 17 00:00:00 2001 From: Carl George Date: Oct 19 2018 19:14:46 +0000 Subject: Initial import (rhbz#1639000) --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1ac9f1f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +python-multipart-*.tar.gz diff --git a/README.md b/README.md deleted file mode 100644 index f8e99b1..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# python-multipart - -A streaming multipart parser for Python \ No newline at end of file diff --git a/python-multipart.spec b/python-multipart.spec new file mode 100644 index 0000000..4c6e974 --- /dev/null +++ b/python-multipart.spec @@ -0,0 +1,151 @@ +# what it's called on pypi +%global srcname python-multipart +# what it's imported as +%global libname multipart +# name of egg info directory +%global eggname python_multipart +# package name fragment +%global pkgname %{libname} + +%global _description \ +python-multipart is an Apache2 licensed streaming multipart parser for Python. + +%if %{defined rhel} +%bcond_without python2 +%bcond_without python2_tests +%bcond_without python3_other +%bcond_with python3_other_tests +%endif + +%bcond_without python3 +%bcond_without python3_tests + + +Name: python-%{pkgname} +Version: 0.0.5 +Release: 2%{?dist} +Summary: A streaming multipart parser for Python +License: ASL 2.0 +URL: https://github.com/andrew-d/python-multipart +Source0: %pypi_source +# https://github.com/andrew-d/python-multipart/pull/18 +Patch0: use-standard-library-mock-when-available.patch +BuildArch: noarch + + +%description %{_description} + + +%if %{with python2} +%package -n python2-%{pkgname} +Summary: %{summary} +BuildRequires: python2-devel +BuildRequires: python2-setuptools +%if %{with python2_tests} +BuildRequires: python2-pytest +BuildRequires: python2-mock +BuildRequires: python2-pyyaml +BuildRequires: python2-six +%endif +Requires: python2-six +%{?python_provide:%python_provide python2-%{pkgname}} + + +%description -n python2-%{pkgname} %{_description} +%endif + + +%if %{with python3} +%package -n python%{python3_pkgversion}-%{pkgname} +Summary: %{summary} +BuildRequires: python%{python3_pkgversion}-devel +BuildRequires: python%{python3_pkgversion}-setuptools +%if %{with python3_tests} +BuildRequires: python%{python3_pkgversion}-pytest +BuildRequires: python%{python3_pkgversion}-PyYAML +BuildRequires: python%{python3_pkgversion}-six +%endif +Requires: python%{python3_pkgversion}-six +%{?python_provide:%python_provide python%{python3_pkgversion}-%{pkgname}} + + +%description -n python%{python3_pkgversion}-%{pkgname} %{_description} +%endif + + +%if %{with python3_other} +%package -n python%{python3_other_pkgversion}-%{pkgname} +Summary: %{summary} +BuildRequires: python%{python3_other_pkgversion}-devel +BuildRequires: python%{python3_other_pkgversion}-setuptools +%if %{with python3_other_tests} +BuildRequires: python%{python3_other_pkgversion}-pytest +BuildRequires: python%{python3_other_pkgversion}-PyYAML +BuildRequires: python%{python3_other_pkgversion}-six +%endif +Requires: python%{python3_other_pkgversion}-six + + +%description -n python%{python3_other_pkgversion}-%{pkgname} %{_description} +%endif + + +%prep +%autosetup -n %{srcname}-%{version} -p 1 +rm -rf %{eggname}.egg-info + + +%build +%{?with_python2:%py2_build} +%{?with_python3:%py3_build} +%{?with_python3_other:%py3_other_build} + + +%install +%{?with_python2:%py2_install} +%{?with_python3:%py3_install} +%{?with_python3_other:%py3_other_install} + + +%check +%{?with_python2_tests:PYTHONPATH=%{buildroot}%{python2_sitelib} py.test-%{python2_version} --verbose multipart/tests} +%{?with_python3_tests:PYTHONPATH=%{buildroot}%{python3_sitelib} py.test-%{python3_version} --verbose multipart/tests} +%{?with_python3_other_tests:PYTHONPATH=%{buildroot}%{python3_other_sitelib} py.test-%{python3_other_version} --verbose multipart/tests} + + +%if %{with python2} +%files -n python2-%{pkgname} +%license LICENSE.txt +%doc README.rst +%{python2_sitelib}/%{libname} +%exclude %{python2_sitelib}/%{libname}/tests +%{python2_sitelib}/%{eggname}-%{version}-py%{python2_version}.egg-info +%endif + + +%if %{with python3} +%files -n python%{python3_pkgversion}-%{pkgname} +%license LICENSE.txt +%doc README.rst +%{python3_sitelib}/%{libname} +%exclude %{python3_sitelib}/%{libname}/tests +%{python3_sitelib}/%{eggname}-%{version}-py%{python3_version}.egg-info +%endif + + +%if %{with python3_other} +%files -n python%{python3_other_pkgversion}-%{pkgname} +%license LICENSE.txt +%doc README.rst +%{python3_other_sitelib}/%{libname} +%exclude %{python3_other_sitelib}/%{libname}/tests +%{python3_other_sitelib}/%{eggname}-%{version}-py%{python3_other_version}.egg-info +%endif + + +%changelog +* Mon Oct 15 2018 Carl George - 0.0.5-2 +- Only build python2 subpackage on RHEL + +* Sun Oct 14 2018 Carl George - 0.0.5-1 +- Initial package diff --git a/sources b/sources new file mode 100644 index 0000000..576b723 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (python-multipart-0.0.5.tar.gz) = 159472175c7b21ddcfb6d026d2efe1dc68ceacb6b30afef7f2aab078542eef6faf61d7e40abb2d22d18346c88e2fbee12283795f3e4a8b1f36673a5dd9163a8e diff --git a/use-standard-library-mock-when-available.patch b/use-standard-library-mock-when-available.patch new file mode 100644 index 0000000..c728440 --- /dev/null +++ b/use-standard-library-mock-when-available.patch @@ -0,0 +1,60 @@ +From a027deb1e41ceedd269507ab938ee05f5113290d Mon Sep 17 00:00:00 2001 +From: Carl George +Date: Sat, 13 Oct 2018 17:25:09 -0500 +Subject: [PATCH] Use standard library mock when available + +--- + multipart/tests/test_multipart.py | 5 ++++- + setup.py | 16 ++++++++++------ + 2 files changed, 14 insertions(+), 7 deletions(-) + +diff --git a/multipart/tests/test_multipart.py b/multipart/tests/test_multipart.py +index dbb7ff1..decf794 100644 +--- a/multipart/tests/test_multipart.py ++++ b/multipart/tests/test_multipart.py +@@ -16,7 +16,10 @@ + from io import BytesIO + from six import binary_type, text_type + +-from mock import MagicMock, Mock, patch ++try: ++ from unittest.mock import MagicMock, Mock, patch ++except ImportError: ++ from mock import MagicMock, Mock, patch + + from ..multipart import * + +diff --git a/setup.py b/setup.py +index 821d337..8e90309 100755 +--- a/setup.py ++++ b/setup.py +@@ -16,6 +16,15 @@ + version_re = re.compile(r'((?:\d+)\.(?:\d+)\.(?:\d+))') + version = version_re.search(version_data).group(0) + ++tests_require = [ ++ 'pytest', ++ 'pytest-cov', ++ 'PyYAML' ++] ++ ++if sys.version_info[0:2] < (3, 3): ++ tests_require.append('mock') ++ + setup(name='python-multipart', + version=version, + description='A streaming multipart parser for Python', +@@ -27,12 +36,7 @@ + install_requires=[ + 'six>=1.4.0', + ], +- tests_require=[ +- 'pytest', +- 'pytest-cov', +- 'Mock', +- 'PyYAML' +- ], ++ tests_require=tests_require, + packages=[ + 'multipart', + 'multipart.tests',