diff --git a/_multibuild b/_multibuild
new file mode 100644
index 0000000..fcc7b97
--- /dev/null
+++ b/_multibuild
@@ -0,0 +1,3 @@
+
+ test
+
diff --git a/pytest4.patch b/pytest4.patch
index 8580b35..57f8ffa 100644
--- a/pytest4.patch
+++ b/pytest4.patch
@@ -1,7 +1,5 @@
-Index: apipkg-1.5/test_apipkg.py
-===================================================================
---- apipkg-1.5.orig/test_apipkg.py
-+++ apipkg-1.5/test_apipkg.py
+--- a/test_apipkg.py
++++ b/test_apipkg.py
@@ -13,7 +13,7 @@ ModuleType = types.ModuleType
class TestRealModule:
diff --git a/python-apipkg.changes b/python-apipkg.changes
index f954866..0524649 100644
--- a/python-apipkg.changes
+++ b/python-apipkg.changes
@@ -1,3 +1,9 @@
+-------------------------------------------------------------------
+Sun Dec 6 11:49:49 UTC 2020 - Matej Cepl
+
+- Split package into multibuild, to avoid apipkg -> pytest -> py ->
+ apipkg cycle.
+
-------------------------------------------------------------------
Fri Jul 19 09:02:40 UTC 2019 - Ondřej Súkup
diff --git a/python-apipkg.spec b/python-apipkg.spec
index e87c04b..298476e 100644
--- a/python-apipkg.spec
+++ b/python-apipkg.spec
@@ -1,7 +1,7 @@
#
-# spec file for package python-apipkg
+# spec file for package python
#
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,15 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
-Name: python-apipkg
+%global flavor @BUILD_FLAVOR@%{nil}
+%if "%{flavor}" == "test"
+%define psuffix -%{flavor}
+%bcond_without test
+%else
+%define psuffix %{nil}
+%bcond_with test
+%endif
+Name: python-apipkg%{psuffix}
Version: 1.5
Release: 0
Summary: Namespace control and lazy-import mechanism
@@ -25,8 +33,13 @@ License: MIT
Group: Development/Languages/Python
URL: https://github.com/pytest-dev/apipkg/
Source: https://files.pythonhosted.org/packages/source/a/apipkg/apipkg-%{version}.tar.gz
+# PATCH-FIX-UPSTREAM pytest4.patch bsc#[0-9]+ mimi.vx@gmail.com
+# Collected upstream fixes for gh#pytest-dev/apipkg#14 and
+# gh#pytest-dev/apipkg#15
Patch0: pytest4.patch
+%if %{with test}
BuildRequires: %{python_module pytest}
+%endif
BuildRequires: %{python_module setuptools_scm}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
@@ -46,24 +59,29 @@ Usage is very simple: you can require 'apipkg' as a dependency or you
can copy paste the <100 Lines of code into your project.
%prep
-%setup -q -n apipkg-%{version}
-%patch0 -p1
+%autosetup -p1 -n apipkg-%{version}
%build
%python_build
%install
+%if ! %{with test}
%python_install
%python_expand %fdupes -s %{buildroot}%{$python_sitelib}
+%endif
%check
-%python_expand PYTHONPATH="%{buildroot}%{$python_sitelib}" $python -m pytest
+%if %{with test}
+%pytest
+%endif
+%if ! %{with test}
%files %{python_files}
%license LICENSE
%doc README.rst CHANGELOG
%dir %{python_sitelib}/apipkg
%{python_sitelib}/apipkg/*
%{python_sitelib}/apipkg-%{version}-py%{python_version}.egg-info
+%endif
%changelog