Re: [PATCH] scripts/sphinx-pre-install: add '-p python3' to virtualenv

From: Mauro Carvalho Chehab
Date: Wed Mar 04 2020 - 14:53:13 EST


Em Wed, 4 Mar 2020 17:25:41 +0000
"Bird, Tim" <Tim.Bird@xxxxxxxx> escreveu:

> > -----Original Message-----
> > From: Jonathan Corbet <corbet@xxxxxxx>
> >
> > On Tue, 3 Mar 2020 17:07:48 +0000
> > "Bird, Tim" <Tim.Bird@xxxxxxxx> wrote:
> >
> > > The less fragile approach would have been to just
> > > always add the '-p python3' option to the virtualenv setup hint,
> > > but Mauro seemed to want something more fine-tuned.
> >
> > At some point I think we'll want to say that Python 2 just isn't supported
> > anymore. After all, the language itself isn't supported anymore. Perhaps
> > it's time to add a warning somewhere.
>
> Probably. IMHO always adding the 'p python3' would have been the
> first vestiges of such a hint, but maybe it should be more explicit.
> A more explicit statement of "watch out if your default python
> interpreter is python2" would have probably shortened some of
> my setup time.

A warning like that makes sense to me.

> Ubuntu 16.04 and Ubuntu 18.04 both include python3, but have
> /usr/bin/python default to python2. So, while the package recommendations
> from the script were good (and sufficient), the virtualenv hint was somewhat
> lacking.

And if you try to change the Ubuntu default to python3, some things break
there (I did that last month using alternates on Ubuntu 19.10 - had to
revert back to python2).

> And, just for full disclosure, I wish there was a way to mark this type of fix
> with a obsolescence flag so it could be removed later. This is the type of
> thing that gets put into a script as a workaround for a transition period, but
> keeps being run 10 years later when it's no longer relevant. Heck, the whole
> virtualenv recommendation might be irrelevant in the next version of Ubuntu
> (but maybe the script already figures that out.)

Actually, virtualenv support was added later ;-)

The script supports both virtualenv and distro package install, although
the current default is to use virtualenv. You can force it to recommend the
distro package with:

$ ./scripts/sphinx-pre-install --no-virtualenv
Detected OS: Fedora release 30 (Thirty).

ERROR: please install "python-sphinx", otherwise, build won't work.
Warning: better to also install "sphinx_rtd_theme".
You should run:

sudo dnf install -y python3-sphinx python3-sphinx_rtd_theme

Can't build as 1 mandatory dependency is missing at ./scripts/sphinx-pre-install line 721.

The main reason why virtualenv is the default is that we need to
ensure a certain minimal version (nowadays, it is recommended at least 1.7.9).
If one is using a LTS distro, the distro-package could be older than that.

With virtualenv, it is easier to fulfill the minimal version (and the
recommended one). You may even have multiple Sphinx versions, with is
quite useful when trying to identify if the html and/or pdf output
is doing the right thing with different toolchain versions.

Thanks,
Mauro