Currently we have "sphinx" and "sphinx_rtd_theme" in a single
group in pythondeps.toml. This means that mkvenv will try to
install them both at once, which doesn't work if sphinx_rtd_theme
depends on a version of Sphinx which is newer than the system
one, even if the "sphinx" we're installing at the same time
would satisfy that dependency. For instance this:

 sphinx = { accepted = ">=8.0.0rc1", installed = "8.0.0rc1", canary = 
"sphinx-build" }
 sphinx_rtd_theme = { accepted = ">=2.1.0rc1", installed = "2.1.0rc1" }

fails like this:

mkvenv: Creating non-isolated virtual environment at 'pyvenv'
mkvenv: checking for meson>=1.1.0
mkvenv: installing meson==1.2.3
mkvenv: checking for sphinx>=8.0.0rc1
mkvenv: checking for sphinx_rtd_theme>=2.1.0rc1
mkvenv: installing sphinx==8.0.0rc1, sphinx_rtd_theme==2.1.0rc1
ERROR: Cannot install sphinx-rtd-theme==2.1.0rc1 and sphinx==8.0.0rc1 because 
these package versions have conflicting dependencies.
ERROR: ResolutionImpossible: for help visit 
https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

*** Ouch! ***

Could not provide build dependency 'sphinx==8.0.0rc1':
 • Python package 'sphinx' version '4.3.2' was found, but isn't suitable.
 • A suitable version could not be obtained from PyPI.

(where 4.3.2 is the system version of sphinx on my system).

Avoid this problem by splitting sphinx_rtd_theme into its own
group in pythondeps, so we can install the new sphinx into the
venv first and the sphinx_rtd_theme afterwards.

Signed-off-by: Peter Maydell <peter.mayd...@linaro.org>
---
I'm just bumbling around in the dark here, hence the RFC tag: maybe
there's a better way to fix this? I ran into this when I was trying
to test the fix for https://gitlab.com/qemu-project/qemu/-/issues/2458
and wanted a newer Sphinx to test with. Unless you also install
the newer RTD theme the new Sphinx will emit some deprecation warnings
about things the theme is doing.
---
 configure       | 7 +++++--
 pythondeps.toml | 3 +++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 019fcbd0ef7..7f9cfbffa2c 100755
--- a/configure
+++ b/configure
@@ -973,9 +973,12 @@ if test "$download" = "enabled" ; then
 fi
 
 if test "$docs" != "disabled" ; then
-    if ! $mkvenv ensuregroup \
+    if ! ( $mkvenv ensuregroup \
          $(test "$docs" = "enabled" && echo "$mkvenv_online_flag") \
-         ${source_path}/pythondeps.toml docs;
+         ${source_path}/pythondeps.toml docs && \
+         $mkvenv ensuregroup \
+         $(test "$docs" = "enabled" && echo "$mkvenv_online_flag") \
+         ${source_path}/pythondeps.toml docs-theme );
     then
         if test "$docs" = "enabled" ; then
             exit 1
diff --git a/pythondeps.toml b/pythondeps.toml
index f6e590fdd86..fdf5579c43e 100644
--- a/pythondeps.toml
+++ b/pythondeps.toml
@@ -24,6 +24,9 @@ meson = { accepted = ">=1.1.0", installed = "1.2.3", canary = 
"meson" }
 [docs]
 # Please keep the installed versions in sync with docs/requirements.txt
 sphinx = { accepted = ">=3.4.3", installed = "5.3.0", canary = "sphinx-build" }
+
+[docs-theme]
+# Please keep the installed versions in sync with docs/requirements.txt
 sphinx_rtd_theme = { accepted = ">=0.5", installed = "1.1.1" }
 
 [avocado]
-- 
2.34.1


Reply via email to