8000 MNT use x.y.z (no rc/beta/etc) for version in sphinx config by adrinjalali · Pull Request #15566 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

MNT use x.y.z (no rc/beta/etc) for version in sphinx config #15566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build_tools/circle/build_doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import os
import warnings
import re
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
Expand Down Expand Up @@ -85,7 +86,7 @@
#
# The short X.Y version.
import sklearn
version = sklearn.__version__
version = parse(sklearn.__version__).base_version
# The full version, including alpha/beta/rc tags.
release = sklearn.__version__

Expand Down Expand Up @@ -245,17 +246,16 @@
'joblib': ('https://joblib.readthedocs.io/en/latest/', None),
}

if 'dev' in version:
v = parse(release)
if v.release is None:
raise ValueError(
'Ill-formed version: {!r}. Version should follow '
'PEP440'.format(version))

if v.is_devrelease:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I am missing something, but I think pkg_resources.parse_version does not return an object with a .is_devrelease attribute. On the other hand, packaging.version.parse does.

In [1]: from packaging.version import parse                                                                                                                                        

In [2]: parse('0.22.dev0').is_devrelease                                                                                                                                           
Out[2]: True

In [3]: from pkg_resources import parse_version                                                                                                                                    

In [4]: parse_version('0.22.dev0').is_devrelease                                                                                                                                   
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-13d9ab197353> in <module>
----> 1 parse_version('0.22.dev0').is_devrelease

AttributeError: 'Version' object has no attribute 'is_devrelease'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rather not have a dependency just to parse the version. And the issue is that the new pkg_resources actually do have the is_devrelease attribute, and it works fine. The older ones however, don't. Trying to figure out when it was added to it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand, setuptools actually ships a version of packaging with it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️ setuptools ships packaging=16.8, whereas Version().is_devrelease was introduced in packaging=17.0. It worked on my system because pkg_resources uses the installed lib instead of the vendored one if it finds it, and I had a new packaging in that environment.

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)


Expand Down
5 changes: 4 additions & 1 deletion doc/developers/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,12 @@ Building the documentation
First, make sure you have :ref:`properly installed <install_bleeding_edge>`
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::

Expand Down
0