From 401c9fd89dce1e6c0dfc67367c1988079d286404 Mon Sep 17 00:00:00 2001 From: Jakub Bogusz Date: Sun, 26 Mar 2023 19:23:02 +0200 Subject: [PATCH] - updated to 0.19.1, pl, cleanup - added mock patch (use unittest.mock instead of separate mock for python3) --- python-zeroconf-mock.patch | 14 ++++++ python-zeroconf.spec | 92 ++++++++++++++++++++++---------------- 2 files changed, 67 insertions(+), 39 deletions(-) create mode 100644 python-zeroconf-mock.patch diff --git a/python-zeroconf-mock.patch b/python-zeroconf-mock.patch new file mode 100644 index 0000000..dcfc402 --- /dev/null +++ b/python-zeroconf-mock.patch @@ -0,0 +1,14 @@ +--- python-zeroconf-0.19.1/test_zeroconf.py.orig 2017-06-13 08:34:17.000000000 +0200 ++++ python-zeroconf-0.19.1/test_zeroconf.py 2023-03-26 17:55:15.249452986 +0200 +@@ -272,7 +272,10 @@ class Names(unittest.TestCase): + assert longest_packet[0] >= r._MAX_MSG_ABSOLUTE - 100 + + # mock zeroconf's logger warning() and debug() +- from mock import patch ++ try: ++ from mock import patch ++ except ImportError: ++ from unittest.mock import patch + patch_warn = patch('zeroconf.log.warning') + patch_debug = patch('zeroconf.log.debug') + mocked_log_warn = patch_warn.start() diff --git a/python-zeroconf.spec b/python-zeroconf.spec index 531b2ef..aa2c41f 100644 --- a/python-zeroconf.spec +++ b/python-zeroconf.spec @@ -1,37 +1,46 @@ # # Conditional build: %bcond_with integration # Integration tests work in mock but fail in Koji with PermissionError -%bcond_with tests # do not perform "make test" -%bcond_without python2 # CPython 2.x module -%bcond_without python3 # CPython 3.x module +%bcond_with tests # unit tests +%bcond_without python2 # CPython 2.x module +%bcond_without python3 # CPython 3.x module -%define pypi_name zeroconf +%define module zeroconf Summary: Pure Python Multicast DNS Service Discovery Library -Name: python-%{pypi_name} -Version: 0.18.0 -Release: 8 -License: LGPLv2 +Summary(pl.UTF-8): Czysto pythonowa biblioteka Multicast DNS Service Discovery +Name: python-%{module} +# keep 0.19.x here for python2 support +Version: 0.19.1 +Release: 1 +License: LGPL v2 Group: Libraries/Python -Source0: https://github.com/jstasiak/%{name}/archive/%{version}/%{pypi_name}-%{version}.tar.gz -# Source0-md5: f40e133a2cec3087761e5230cdf8637c -URL: https://github.com/jstasiak/python-%{pypi_name} +#Source0Download: https://github.com/jstasiak/python-zeroconf/releases +Source0: https://github.com/jstasiak/python-zeroconf/archive/%{version}/%{module}-%{version}.tar.gz +# Source0-md5: bda83913df1669610ba3c09f8133614e +Patch0: %{name}-mock.patch +URL: https://github.com/jstasiak/python-zeroconf %if %{with python2} -BuildRequires: python-devel +BuildRequires: python-devel >= 1:2.6 +BuildRequires: python-setuptools +%if %{with tests} BuildRequires: python-enum34 BuildRequires: python-mock -BuildRequires: python-netifaces +BuildRequires: python-netifaces >= 0.10.6 BuildRequires: python-pytest -BuildRequires: python-setuptools BuildRequires: python-six %endif +%endif %if %{with python3} -BuildRequires: python3-devel -BuildRequires: python3-mock -BuildRequires: python3-netifaces -BuildRequires: python3-pytest +BuildRequires: python3-devel >= 1:3.4 BuildRequires: python3-setuptools +%if %{with tests} +BuildRequires: python3-netifaces >= 0.10.6 +BuildRequires: python3-pytest BuildRequires: python3-six %endif +%endif +BuildRequires: rpm-pythonprov +BuildRequires: rpmbuild(macros) >= 1.714 BuildArch: noarch BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) @@ -39,18 +48,26 @@ BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) A pure Python implementation of multicast DNS service discovery supporting Bonjour/Avahi. -%package -n python3-%{pypi_name} -Summary: Pure Python 3 Multicast DNS Service Discovery Library +%description -l pl.UTF-8 +Czysto pythonowa implementacja wykrywania usług multicastowych DNS +przy użyciu Bonjour/Avahi. + +%package -n python3-%{module} +Summary: Pure Python Multicast DNS Service Discovery Library +Summary(pl.UTF-8): Czysto pythonowa biblioteka Multicast DNS Service Discovery Group: Libraries/Python -Requires: python3-netifaces -Requires: python3-six -%description -n python3-%{pypi_name} -A pure Python 3 implementation of multicast DNS service discovery +%description -n python3-%{module} +A pure Python implementation of multicast DNS service discovery supporting Bonjour/Avahi. +%description -n python3-%{module} -l pl.UTF-8 +Czysto pythonowa implementacja wykrywania usług multicastowych DNS +przy użyciu Bonjour/Avahi. + %prep %setup -q +%patch0 -p1 # Remove enum-compat from install_requires # See https://bugzilla.redhat.com/show_bug.cgi?id=1432165 @@ -59,18 +76,21 @@ sed -i '/enum-compat/d' setup.py %build %if %{with python2} %py_build + %if %{with tests} +PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \ %{__python} -m pytest \ - %{!?with_integartion:-k "not integration"} + %{!?with_integration:-k "not integration"} %endif %endif %if %{with python3} -%py3_build %{?with_tests:test} +%py3_build %if %{with tests} +PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \ %{__python3} -m pytest \ - %{!?with_integartion:-k "not integration"} + %{!?with_integration:-k "not integration"} %endif %endif @@ -80,12 +100,6 @@ rm -rf $RPM_BUILD_ROOT %if %{with python2} %py_install -# when files are installed in other way that standard 'setup.py -# they need to be (re-)compiled -# change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages! -%py_ocomp $RPM_BUILD_ROOT%{py_sitedir} -%py_comp $RPM_BUILD_ROOT%{py_sitedir} - %py_postclean %endif @@ -100,15 +114,15 @@ rm -rf $RPM_BUILD_ROOT %files %defattr(644,root,root,755) %doc README.rst -%{py_sitescriptdir}/%{pypi_name}.py[co] -%{py_sitescriptdir}/%{pypi_name}-%{version}-py*.egg-info +%{py_sitescriptdir}/zeroconf.py[co] +%{py_sitescriptdir}/zeroconf-%{version}-py*.egg-info %endif %if %{with python3} -%files -n python3-%{pypi_name} +%files -n python3-%{module} %defattr(644,root,root,755) %doc README.rst -%{py3_sitescriptdir}/__pycache__/* -%{py3_sitescriptdir}/%{pypi_name}.py -%{py3_sitescriptdir}/%{pypi_name}-%{version}-py*.egg-info +%{py3_sitescriptdir}/__pycache__/zeroconf.cpython-*.py[co] +%{py3_sitescriptdir}/zeroconf.py +%{py3_sitescriptdir}/zeroconf-%{version}-py*.egg-info %endif -- 2.44.0