Skip to contentSkip to conversation

docs: drop the version constraints for sphinx and dependencies

PATCH Superseded Lukas Bulwahn 4 participants 7 messages Feb 27, 2024 – Mar 1, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 docs: drop the version constraints for sphinx and dependencies

As discussed (see Links), there is some inertia to move to the recent Sphinx versions for the doc build environment.

As first step, drop the version constraints and the related comments. Then, the sphinx-pre-install script will fail though with:

Can't get default sphinx version from ./Documentation/sphinx/requirements.txt at ./scripts/sphinx-pre-install line 305.

The script simply expects to parse a version constraint with Sphinx in the requirements.txt. That version is used in the script for suggesting the virtualenv directory name.

To suggest a virtualenv directory name, when there is no version given in the requirements.txt, one could try to guess the version that would be downloaded with 'pip install -r Documentation/sphinx/requirements.txt'. However, there seems no simple way to get that version without actually setting up the venv and running pip. So, instead, name the directory with the fixed name 'sphinx_latest'.

Finally update the Sphinx build documentation to reflect this directory name change.

---
 Documentation/doc-guide/sphinx.rst    | 11 ++++++-----
 Documentation/sphinx/requirements.txt |  8 +++-----
 scripts/sphinx-pre-install            | 19 +++----------------
 3 files changed, 12 insertions(+), 26 deletions(-)
Documentation/doc-guide/sphinx.rst +6 -5
index 709e19821a16..8081ebfe48bc 100644
@@ -48,13 +48,14 @@ or ``virtualenv``, depending on how your distribution packaged Python 3.
       on the Sphinx version, it should be installed separately,
       with ``pip install sphinx_rtd_theme``.
 
-In summary, if you want to install Sphinx version 2.4.4, you should do::
+In summary, if you want to install the latest version of Sphinx, you
+should do::
 
-       $ virtualenv sphinx_2.4.4
-       $ . sphinx_2.4.4/bin/activate
-       (sphinx_2.4.4) $ pip install -r Documentation/sphinx/requirements.txt
+       $ virtualenv sphinx_latest
+       $ . sphinx_latest/bin/activate
+       (sphinx_latest) $ pip install -r Documentation/sphinx/requirements.txt
 
-After running ``. sphinx_2.4.4/bin/activate``, the prompt will change,
+After running ``. sphinx_latest/bin/activate``, the prompt will change,
 in order to indicate that you're using the new environment. If you
 open a new shell, you need to rerun this command to enter again at
 the virtual environment before building the documentation.
Documentation/sphinx/requirements.txt +3 -5
index 5d47ed443949..1f3b98eee2c9 100644
@@ -1,6 +1,4 @@
-# jinja2>=3.1 is not compatible with Sphinx<4.0
-jinja2<3.1
-# alabaster>=0.7.14 is not compatible with Sphinx<=3.3
-alabaster<0.7.14
-Sphinx==2.4.4
+jinja2
+alabaster
+Sphinx
 pyyaml
scripts/sphinx-pre-install +3 -16
index de0de5dd676e..4c781617ffe6 100755
@@ -280,8 +280,6 @@ sub get_sphinx_version($)
 
 sub check_sphinx()
 {
-	my $default_version;
-
 	open IN, $conf or die "Can't open $conf";
 	while (<IN>) {
 		if (m/^\s*needs_sphinx\s*=\s*[\'\"]([\d\.]+)[\'\"]/) {
@@ -293,18 +291,7 @@ sub check_sphinx()
 
 	die "Can't get needs_sphinx version from $conf" if (!$min_version);
 
-	open IN, $requirement_file or die "Can't open $requirement_file";
-	while (<IN>) {
-		if (m/^\s*Sphinx\s*==\s*([\d\.]+)$/) {
-			$default_version=$1;
-			last;
-		}
-	}
-	close IN;
-
-	die "Can't get default sphinx version from $requirement_file" if (!$default_version);
-
-	$virtenv_dir = $virtenv_prefix . $default_version;
+	$virtenv_dir = $virtenv_prefix . "latest";
 
 	my $sphinx = get_sphinx_fname();
 	if ($sphinx eq "") {
@@ -318,8 +305,8 @@ sub check_sphinx()
 	die "$sphinx didn't return its version" if (!$cur_version);
 
 	if ($cur_version lt $min_version) {
-		printf "ERROR: Sphinx version is %s. It should be >= %s (recommended >= %s)\n",
-		       $cur_version, $min_version, $default_version;
+		printf "ERROR: Sphinx version is %s. It should be >= %s\n",
+		       $cur_version, $min_version;
 		$need_sphinx = 1;
 		return;
 	}
Signature · 1 line
2.43.2
#1 lore raw
Quoted 20 lines · Lukas Bulwahn

As discussed (see Links), there is some inertia to move to the recent Sphinx versions for the doc build environment.

As first step, drop the version constraints and the related comments. Then, the sphinx-pre-install script will fail though with:

Can't get default sphinx version from ./Documentation/sphinx/requirements.txt at ./scripts/sphinx-pre-install line 305.

The script simply expects to parse a version constraint with Sphinx in the requirements.txt. That version is used in the script for suggesting the virtualenv directory name.

To suggest a virtualenv directory name, when there is no version given in the requirements.txt, one could try to guess the version that would be downloaded with 'pip install -r Documentation/sphinx/requirements.txt'. However, there seems no simple way to get that version without actually setting up the venv and running pip. So, instead, name the directory with the fixed name 'sphinx_latest'.

Quoted 7 lines

Finally update the Sphinx build documentation to reflect this directory name change.

Oops, I was a bit quick on sending this out, I wanted to add those remarks for the patch discussion:

This change seems to work for my setup, but I have really only dipped my toes into the waters of this sphinx-pre-install script.

I only dropped the version constraints, but possibly one can even drop some of the packages in the requirements.txt, as they are pulled in automatically by Sphinx dependencies.

So, I am happy to get your feedback, but I am well aware about its potential to be improved and the lack of my deep knowledge about the script. I hope, though, you can test it in your setup and confirm if it works as expected and then we can discuss the details (e.g., naming).

Lukas

maintainer
#2 lore raw
Quoted 6 lines · Lukas Bulwahn

This change seems to work for my setup, but I have really only dipped my toes into the waters of this sphinx-pre-install script.

I only dropped the version constraints, but possibly one can even drop some of the packages in the requirements.txt, as they are pulled in automatically by Sphinx dependencies.

That's a cleanup we can do at any time, I guess. I note that not all of them get pulled in correctly, though; after installing 7.2.6 with pip, I still had to get pyyaml separately before it would work.

Quoted 5 lines

So, I am happy to get your feedback, but I am well aware about its potential to be improved and the lack of my deep knowledge about the script. I hope, though, you can test it in your setup and confirm if it works as expected and then we can discuss the details (e.g., naming).

I think this is the direction we need to go. We can add a separate requirements file for successful installation of 2.4.x later if that's really needed. Unless I hear screams, my plan is to apply this.

Thanks,

jon

Tested-by on v1 1/1
#3 lore raw
In reply to Lukas Bulwahn
Quoted 2 lines · Lukas Bulwahn

As discussed (see Links), there is some inertia to move to the recent Sphinx versions for the doc build environment.

[...]

Quoted 5 lines
Documentation/sphinx/requirements.txt +0 -0
index 5d47ed443949..1f3b98eee2c9 100644

Documentation/sphinx/requirements.txt line 4

Quoted 9 lines
Documentation/sphinx/requirements.txt +3 -5
@@ -1,6 +1,4 @@
-# jinja2>=3.1 is not compatible with Sphinx<4.0
-jinja2<3.1
-# alabaster>=0.7.14 is not compatible with Sphinx<=3.3
-alabaster<0.7.14
-Sphinx==2.4.4
+jinja2
+alabaster
+Sphinx
  pyyaml

I know you wrote this as well, but just for the record I tried dropping jinja2 from this list and it still pulled it in automatically:

Collecting Jinja2>=3.0
Using cached Jinja2-3.1.3-py3-none-any.whl (133 kB)

Quoted 34 lines
scripts/sphinx-pre-install +1 -14
index de0de5dd676e..4c781617ffe6 100755
@@ -280,8 +280,6 @@ sub get_sphinx_version($)
 
  sub check_sphinx()
  {
-	my $default_version;
-
  	open IN, $conf or die "Can't open $conf";
  	while (<IN>) {
  		if (m/^\s*needs_sphinx\s*=\s*[\'\"]([\d\.]+)[\'\"]/) {
@@ -293,18 +291,7 @@ sub check_sphinx()
 
  	die "Can't get needs_sphinx version from $conf" if (!$min_version);
 
-	open IN, $requirement_file or die "Can't open $requirement_file";
-	while (<IN>) {
-		if (m/^\s*Sphinx\s*==\s*([\d\.]+)$/) {
-			$default_version=$1;
-			last;
-		}
-	}
-	close IN;
-
-	die "Can't get default sphinx version from $requirement_file" if (!$default_version);
-
-	$virtenv_dir = $virtenv_prefix . $default_version;
+	$virtenv_dir = $virtenv_prefix . "latest";
 
  	my $sphinx = get_sphinx_fname();
  	if ($sphinx eq "") {

scripts/sphinx-pre-install sub check_sphinx() · line 312

Quoted 10 lines
scripts/sphinx-pre-install +2 -2
@@ -318,8 +305,8 @@ sub check_sphinx()
  	die "$sphinx didn't return its version" if (!$cur_version);
 
  	if ($cur_version lt $min_version) {
-		printf "ERROR: Sphinx version is %s. It should be >= %s (recommended >= %s)\n",
-		       $cur_version, $min_version, $default_version;
+		printf "ERROR: Sphinx version is %s. It should be >= %s\n",
+		       $cur_version, $min_version;
  		$need_sphinx = 1;
  		return;
  	}

Tried with a few different versions:

$ (. sphinx-2.4.4/bin/activate && scripts/sphinx-pre-install)
Detected OS: Ubuntu 22.04.3 LTS.
Sphinx version: 2.4.4

You may also use the newer Sphinx version 7.2.6 with:
. /home/vegard/linux/sphinx_latest/bin/activate
[...]

$ (. sphinx-2.0/bin/activate && scripts/sphinx-pre-install)
ERROR: Sphinx version is 2.0.0. It should be >= 2.4.4
Detected OS: Ubuntu 22.04.3 LTS.
Sphinx version: 2.0.0

Need to activate Sphinx (version 7.2.6) on virtualenv with:
. /home/vegard/linux/sphinx_latest/bin/activate
[...]

$ scripts/sphinx-pre-install
Detected OS: Ubuntu 22.04.3 LTS.
Sphinx version: 4.3.2

All optional dependencies are met.
Needed package dependencies are met.

One remark I have is that it didn't encourage me to upgrade to 7.2.6 in the last one (using the system Sphinx 4.3.2) although it did for the 2.4.4 virtualenv. Maybe that's expected. I didn't look into it. Anyway, FWIW:

Vegard

Reviewed-by
#4 lore raw
Quoted 7 lines · Vegard Nossum

[...]

$ scripts/sphinx-pre-install
Detected OS: Ubuntu 22.04.3 LTS.
Sphinx version: 4.3.2
Quoted 7 lines

All optional dependencies are met.
Needed package dependencies are met.

One remark I have is that it didn't encourage me to upgrade to 7.2.6 in the last one (using the system Sphinx 4.3.2) although it did for the 2.4.4 virtualenv. Maybe that's expected. I didn't look into it. Anyway,

Yes, it's expected.

Sphinx 3.4.3 provided as distro packages of Debian 11 (bullseye), RHEL 9, and so on is good enough for kernel documentation. Suggesting upgrade to a latest release would be noisy.

The version is assigned to $rec_version in sphinx-pre-install.

As a fix to requirements.txt for v6.8, this looks to me like a nice minimal change.

Lukas, many thanks for doing this.

Thanks, Akira

#6 lore raw
In reply to Vegard Nossum
Quoted 17 lines · Vegard Nossum
Quoted 2 lines · Lukas Bulwahn

As discussed (see Links), there is some inertia to move to the recent Sphinx versions for the doc build environment.

[...]

Quoted 9 lines
Documentation/sphinx/requirements.txt +0 -4
index 5d47ed443949..1f3b98eee2c9 100644
@@ -1,6 +1,4 @@
-# jinja2>=3.1 is not compatible with Sphinx<4.0
-jinja2<3.1
-# alabaster>=0.7.14 is not compatible with Sphinx<=3.3
-alabaster<0.7.14
Quoted 8 lines

Documentation/sphinx/requirements.txt line 4

Quoted 5 lines
Documentation/sphinx/requirements.txt +3 -1
-Sphinx==2.4.4
+jinja2
+alabaster
+Sphinx
  pyyaml

I know you wrote this as well, but just for the record I tried dropping jinja2 from this list and it still pulled it in automatically:

Vegard, I took your suggestion and removed jinja2 from the requirements.txt in my patch v2:

https://lore.kernel.org/linux-doc/[email protected]/

So, there is no need for any further future one-line deletion patch.

Jonathan, please pick the patch v2.

Lukas