Re: [PATCH] Documentation/sphinx more portable version check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 16 Dec 2016, Robert Bragg <robert@xxxxxxxxxxxxx> wrote:
> The sphinx.__version__ string doesn't always include a patch version and
> so the previous tuple decomposition failed with to few elements.
>
> Since I hit the case with no patch version ("1.5"), I guess it's
> possible a major release might elide the minor version.
>
> Although there's an alternative sphinx.version_info tuple that looks
> generally preferable to splitting the __version__ string, this opts to
> continue using __version__ which existed prior to v 1.2.

IMO just go for sphinx.version_info for simplicity and per [1], and
ignore Sphinx v1.1 and older. Even Debian stable has v1.2.

BR,
Jani.

[1] http://www.sphinx-doc.org/en/1.5.1/extdev/appapi.html#checking-the-sphinx-version


>
> Signed-off-by: Robert Bragg <robert@xxxxxxxxxxxxx>
> Cc: Mauro Carvalho Chehab <mchehab@xxxxxxxxxxxxxxxx>
> Cc: Jonathan Corbet <corbet@xxxxxxx>
> ---
>  Documentation/conf.py           | 4 +++-
>  Documentation/sphinx/cdomain.py | 4 +++-
>  2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/conf.py b/Documentation/conf.py
> index 1ac958c..6ecbd7b 100644
> --- a/Documentation/conf.py
> +++ b/Documentation/conf.py
> @@ -17,7 +17,9 @@ import os
>  import sphinx
>  
>  # Get Sphinx version
> -major, minor, patch = map(int, sphinx.__version__.split("."))
> +# Note: sphinx.version_info only exists >= 1.2, and __version__ may not
> +# include patch version (unknown if minor may be elided too)
> +(major, minor, patch) = list(map(int, (sphinx.__version__ + ".0.0").split(".")))[:3]
>  
>  
>  # If extensions (or modules to document with autodoc) are in another directory,
> diff --git a/Documentation/sphinx/cdomain.py b/Documentation/sphinx/cdomain.py
> index df0419c..7ffcebd 100644
> --- a/Documentation/sphinx/cdomain.py
> +++ b/Documentation/sphinx/cdomain.py
> @@ -44,7 +44,9 @@ from sphinx.domains.c import CDomain as Base_CDomain
>  __version__  = '1.0'
>  
>  # Get Sphinx version
> -major, minor, patch = map(int, sphinx.__version__.split("."))
> +# Note: sphinx.version_info only exists >= 1.2, and __version__ may not
> +# include patch version (unknown if minor may be elided too)
> +(major, minor, patch) = list(map(int, (sphinx.__version__ + ".0.0").split(".")))[:3]
>  
>  def setup(app):

-- 
Jani Nikula, Intel Open Source Technology Center
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux