From f872a721744556a091f53016ccd3ed88f0a6958f Mon Sep 17 00:00:00 2001 From: adrinjalali Date: Thu, 7 Nov 2019 23:43:53 +0100 Subject: [PATCH 1/4] use x.y.z (no rc/beta/etc) for version in sphinx config --- doc/conf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index ea7dc2ff6b091..ca82120d75e96 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -16,6 +16,7 @@ import os import warnings import re +from distutils.version import StrictVersion # If extensions (or modules to document with autodoc) are in another # directory, add these directories to sys.path here. If the directory @@ -85,7 +86,8 @@ # # The short X.Y version. import sklearn -version = sklearn.__version__ +version = '.'.join([str(x) for x in + StrictVersion(sklearn.__version__).version]) # The full version, including alpha/beta/rc tags. release = sklearn.__version__ From 755cc2a8e3707f8005b9c89c3999d6167eae6ed2 Mon Sep 17 00:00:00 2001 From: adrinjalali Date: Fri, 8 Nov 2019 11:07:18 +0100 Subject: [PATCH 2/4] use parse_version, and refactor binder branch inference --- doc/conf.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index ca82120d75e96..716caa5d1d66e 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -16,7 +16,7 @@ import os import warnings import re -from distutils.version import StrictVersion +from pkg_resources import parse_version # If extensions (or modules to document with autodoc) are in another # directory, add these directories to sys.path here. If the directory @@ -86,8 +86,7 @@ # # The short X.Y version. import sklearn -version = '.'.join([str(x) for x in - StrictVersion(sklearn.__version__).version]) +version = parse_version(sklearn.__version__).base_version # The full version, including alpha/beta/rc tags. release = sklearn.__version__ @@ -247,17 +246,16 @@ 'joblib': ('https://joblib.readthedocs.io/en/latest/', None), } -if 'dev' in version: +v = parse_version(release) +if v.release is None: + raise ValueError( + 'Ill-formed version: {!r}. Version should follow ' + 'PEP440'.format(version)) + +if v.is_devrelease: binder_branch = 'master' else: - match = re.match(r'^(\d+)\.(\d+)(?:\.\d+)?$', version) - if match is None: - raise ValueError( - 'Ill-formed version: {!r}. Expected either ' - "a version containing 'dev' " - 'or a version like X.Y or X.Y.Z.'.format(version)) - - major, minor = match.groups() + major, minor = v.release[:2] binder_branch = '{}.{}.X'.format(major, minor) From 22d3451f21ff521eeb108c10a7f028aadc7cf83c Mon Sep 17 00:00:00 2001 From: adrinjalali Date: Fri, 8 Nov 2019 15:00:52 +0100 Subject: [PATCH 3/4] install packaging in doc build envs --- build_tools/circle/build_doc.sh | 3 ++- doc/developers/contributing.rst | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build_tools/circle/build_doc.sh b/build_tools/circle/build_doc.sh index c67278f4a5b85..a76f9a8a890c4 100755 --- a/build_tools/circle/build_doc.sh +++ b/build_tools/circle/build_doc.sh @@ -125,12 +125,13 @@ if [[ "$CIRCLE_JOB" == "doc-min-dependencies" ]]; then conda config --set restore_free_channel true fi +# packaging won't be needed once setuptools starts shipping packaging>=17.0 conda create -n $CONDA_ENV_NAME --yes --quiet python="${PYTHON_VERSION:-*}" \ numpy="${NUMPY_VERSION:-*}" scipy="${SCIPY_VERSION:-*}" \ cython="${CYTHON_VERSION:-*}" pytest coverage \ matplotlib="${MATPLOTLIB_VERSION:-*}" sphinx=2.1.2 pillow \ scikit-image="${SCIKIT_IMAGE_VERSION:-*}" pandas="${PANDAS_VERSION:-*}" \ - joblib memory_profiler + joblib memory_profiler packaging source activate testenv pip install sphinx-gallery==0.3.1 diff --git a/doc/developers/contributing.rst b/doc/developers/contributing.rst index b8db85672d6f3..863ecfb7741b3 100644 --- a/doc/developers/contributing.rst +++ b/doc/developers/contributing.rst @@ -537,9 +537,12 @@ Building the documentation First, make sure you have :ref:`properly installed ` the development version. +.. + packaging is not needed once setuptools starts shipping packaging>=17.0 + Building the documentation requires installing some additional packages:: - pip install sphinx sphinx-gallery numpydoc matplotlib Pillow pandas scikit-image + pip install sphinx sphinx-gallery numpydoc matplotlib Pillow pandas scikit-image packaging To build the documentation, you need to be in the ``doc`` folder:: From 44891642bc08fd64d1192d234680fbd1e84cf59e Mon Sep 17 00:00:00 2001 From: adrinjalali Date: Fri, 8 Nov 2019 15:21:09 +0100 Subject: [PATCH 4/4] use packaging --- doc/conf.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 716caa5d1d66e..7959a0862f547 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -16,7 +16,7 @@ import os import warnings import re -from pkg_resources import parse_version +from packaging.version import parse # If extensions (or modules to document with autodoc) are in another # directory, add these directories to sys.path here. If the directory @@ -86,7 +86,7 @@ # # The short X.Y version. import sklearn -version = parse_version(sklearn.__version__).base_version +version = parse(sklearn.__version__).base_version # The full version, including alpha/beta/rc tags. release = sklearn.__version__ @@ -246,7 +246,7 @@ 'joblib': ('https://joblib.readthedocs.io/en/latest/', None), } -v = parse_version(release) +v = parse(release) if v.release is None: raise ValueError( 'Ill-formed version: {!r}. Version should follow '