diff --git a/_multibuild b/_multibuild
new file mode 100644
index 0000000..58ef5ee
--- /dev/null
+++ b/_multibuild
@@ -0,0 +1,3 @@
+
+ doc
+
diff --git a/python-atomicwrites-doc.changes b/python-atomicwrites-doc.changes
deleted file mode 100644
index 60b5f22..0000000
--- a/python-atomicwrites-doc.changes
+++ /dev/null
@@ -1,69 +0,0 @@
--------------------------------------------------------------------
-Fri Mar 1 09:59:54 UTC 2019 - Ondřej Súkup
-
-- update to 1.3.0
- * Restore ability to use tempfile kwargs other than dir
- * Avoid API breakage under Python 2
- * Passes kwargs through AtomicWriter to tempfile.NamedTemporaryFile
-
--------------------------------------------------------------------
-Wed Jul 18 11:56:07 UTC 2018 - tchvatal@suse.com
-
-- Versionify the provides to make old brp-checks happy
-
--------------------------------------------------------------------
-Thu Jun 7 17:16:00 UTC 2018 - toddrme2178@gmail.com
-
-- Create separate -doc subpackage to build docs.
-- Run tests in -doc subpackage to avoid dependency loop with
- python-pytest.
-- Use license tag
-
--------------------------------------------------------------------
-Fri Jun 30 16:49:02 UTC 2017 - aloisio@gmx.com
-
-- Converted to single-spec
-
--------------------------------------------------------------------
-Wed Sep 21 02:05:33 UTC 2016 - arun@gmx.de
-
-- update to version 1.1.5:
- * Fix toxfile (#21)
- * Make atomic_write work on paths with no directory separator (#20)
- * Fix formatting
- * Skip stylecheck under py26
- * Add contributing.rst
- * Fix tox.ini
-
--------------------------------------------------------------------
-Sun May 8 07:16:22 UTC 2016 - arun@gmx.de
-
-- specfile:
- * updated source url to files.pythonhosted.org
-
--------------------------------------------------------------------
-Sat Mar 26 04:20:01 UTC 2016 - arun@gmx.de
-
-- update to version 1.0.0:
- * Fix unintentional exception clobbering when rollback fails
- * Remove unused variable (fixes an unused variable warning)
- * Update copyright notice
- * Fix appveyor build
-
--------------------------------------------------------------------
-Mon Feb 15 18:11:26 UTC 2016 - arun@gmx.de
-
-- update to version 0.1.9:
- * Fix UnboundLocalError
-
--------------------------------------------------------------------
-Tue Jan 19 11:45:45 UTC 2016 - sleep_walker@opensuse.org
-
-- clean the spec file (not only) with spec-cleaner
-- fix %check part
-
--------------------------------------------------------------------
-Mon Jan 18 23:25:46 UTC 2016 - sleep_walker@opensuse.org
-
-- let there be python3-atomicwrites
-
diff --git a/python-atomicwrites-doc.spec b/python-atomicwrites-doc.spec
deleted file mode 100644
index 7c3cdc7..0000000
--- a/python-atomicwrites-doc.spec
+++ /dev/null
@@ -1,76 +0,0 @@
-#
-# spec file for package python-atomicwrites-doc
-#
-# 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
-# upon. The license for this file, and modifications and additions to the
-# file, is the same license as for the pristine package itself (unless the
-# license for the pristine package is not an Open Source License, in which
-# case the license is the MIT License). An "Open Source License" is a
-# license that conforms to the Open Source Definition (Version 1.9)
-# published by the Open Source Initiative.
-
-# Please submit bugfixes or comments via https://bugs.opensuse.org/
-#
-
-
-# This package allows us to test the package without a dependency loop with python-pytest
-# Please do not delete it
-
-%{?!python_module:%define python_module() python-%{**} python3-%{**}}
-Name: python-atomicwrites-doc
-Version: 1.4.0
-Release: 0
-Summary: Documentation for the Python atomic write support
-License: MIT
-Group: Documentation/HTML
-URL: https://github.com/untitaker/python-atomicwrites
-Source: https://files.pythonhosted.org/packages/source/a/atomicwrites/atomicwrites-%{version}.tar.gz
-BuildRequires: %{python_module atomicwrites}
-BuildRequires: %{python_module pytest}
-BuildRequires: %{python_module setuptools}
-BuildRequires: fdupes
-BuildRequires: python-rpm-macros
-BuildRequires: python3-Sphinx
-Provides: %{python_module atomicwrites-doc = %{version}}
-BuildArch: noarch
-
-%description
-Atomic file writes for python.
-Features that distinguish it from other similar libraries:
-
-- Race-free assertion that the target file doesn't yet exist. This can be
- controlled with the 'overwrite' parameter.
-
-- high-level API that wraps a very flexible class-based API.
-
-This package contains the documentation for both python2 and python3 versions
-of python-atomicwrites
-
-%prep
-%setup -q -n atomicwrites-%{version}
-
-%build
-pushd docs
-make html
-rm _build/html/.buildinfo
-popd
-
-%install
-# not needed
-
-%check
-%{python_expand rm -rf tests/__pycache__
-export PYTHONDONTWRITEBYTECODE=1
-py.test-%{$python_bin_suffix}
-}
-
-%files
-%defattr(-,root,root,-)
-%doc docs/_build/html
-%doc README.rst
-%license LICENSE
-
-%changelog
diff --git a/python-atomicwrites.changes b/python-atomicwrites.changes
index 8402426..39a2018 100644
--- a/python-atomicwrites.changes
+++ b/python-atomicwrites.changes
@@ -1,3 +1,8 @@
+-------------------------------------------------------------------
+Fri Jan 28 21:18:35 UTC 2022 - Matej Cepl
+
+- Rewrite into proper multibuild style.
+
-------------------------------------------------------------------
Tue May 12 08:51:32 UTC 2020 - Dirk Mueller
@@ -23,6 +28,11 @@ Tue Dec 4 13:06:02 UTC 2018 - Matej Cepl
- Remove superfluous devel dependency for noarch package
+-------------------------------------------------------------------
+Wed Jul 18 11:56:07 UTC 2018 - tchvatal@suse.com
+
+- Versionify the provides to make old brp-checks happy
+
-------------------------------------------------------------------
Sun Jun 10 23:51:43 UTC 2018 - jengelh@inai.de
diff --git a/python-atomicwrites.spec b/python-atomicwrites.spec
index bd34534..b287ce9 100644
--- a/python-atomicwrites.spec
+++ b/python-atomicwrites.spec
@@ -1,7 +1,7 @@
#
-# spec file for package python-atomicwrites
+# spec file
#
-# Copyright (c) 2020 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -16,8 +16,15 @@
#
-%{?!python_module:%define python_module() python-%{**} python3-%{**}}
-Name: python-atomicwrites
+%global flavor @BUILD_FLAVOR@%{nil}
+%if "%{flavor}" == "doc"
+%define psuffix -doc
+%bcond_without doc
+%else
+%define psuffix %{nil}
+%bcond_with doc
+%endif
+Name: python-atomicwrites%{psuffix}
Version: 1.4.0
Release: 0
Summary: Atomic file writes for Python
@@ -29,7 +36,12 @@ BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildArch: noarch
-
+%if %{with doc}
+BuildRequires: %{python_module atomicwrites}
+BuildRequires: %{python_module pytest}
+BuildRequires: python3-Sphinx
+Provides: %{python_module atomicwrites-doc = %{version}}
+%endif
%python_subpackages
%description
@@ -45,17 +57,59 @@ Features that distinguish it from other similar libraries:
%setup -q -n atomicwrites-%{version}
rm -rf atomicwrites.egg-info
+%if %{with doc}
+%package -n %{name}-doc
+Summary: Atomic file writes for Python (documentation)
+Group: Documentation/HTML
+
+%description -n %{name}-doc
+Atomic file writes for python3.
+Features that distinguish it from other similar libraries:
+
+- Race-free assertion that the target file doesn't yet exist. This can be
+ controlled with the 'overwrite' parameter.
+
+- High-level API that wraps a very flexible class-based API.
+
+This package contains the documentation for both python2 and python3 versions
+of python-atomicwrites
+%endif
+
%build
+%if %{without doc}
%python_build
+%else
+pushd docs
+make html
+rm _build/html/.buildinfo
+popd
+%endif
%install
+%if %{without doc}
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
+%endif
+%check
+%if %{with doc}
+%pytest
+%endif
+
+%if %{without doc}
%files %{python_files}
%defattr(-,root,root,-)
%doc README.rst
%license LICENSE
-%{python_sitelib}/*
+%{python_sitelib}/atomicwrites*
+
+%else
+
+%files -n %{name}-doc
+%defattr(-,root,root,-)
+%doc README.rst
+%license LICENSE
+%doc docs/_build/html
+%endif
%changelog