diff --git a/docs/changelog.md b/docs/changelog.md index 5de34956..76fe8dfd 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,7 +2,7 @@ ### 0.7.9 - (In Progress) - - TBD + - Swapped from deprecated `disutils.version` to `packaging.version`. PR [#79](https://github.com/smarie/mkdocs-gallery/pull/79) by [Samreay](https://github.com/Samreay) ### 0.7.8 - Bugfixes diff --git a/setup.cfg b/setup.cfg index 88b7ed94..daab6055 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,6 +40,7 @@ install_requires = mkdocs>=1,<2 mkdocs-material tqdm + packaging tests_require = pytest # for some reason these pytest dependencies were not declared in old versions of pytest diff --git a/src/mkdocs_gallery/py_source_parser.py b/src/mkdocs_gallery/py_source_parser.py index 40097ee1..4f81ab8a 100644 --- a/src/mkdocs_gallery/py_source_parser.py +++ b/src/mkdocs_gallery/py_source_parser.py @@ -10,10 +10,10 @@ from __future__ import absolute_import, division, print_function import ast +import platform import re -import sys import tokenize -from distutils.version import LooseVersion +from packaging.version import parse as parse_version from io import BytesIO from pathlib import Path from textwrap import dedent @@ -106,7 +106,7 @@ def _get_docstring_and_rest(file: Path): 'unless the file is ignored by "ignore_pattern"' ) - if LooseVersion(sys.version) >= LooseVersion("3.7"): + if parse_version(platform.python_version()) >= parse_version("3.7"): docstring = ast.get_docstring(node) assert docstring is not None # noqa # should be guaranteed above # This is just for backward compat diff --git a/src/mkdocs_gallery/scrapers.py b/src/mkdocs_gallery/scrapers.py index 2017dc19..39476014 100644 --- a/src/mkdocs_gallery/scrapers.py +++ b/src/mkdocs_gallery/scrapers.py @@ -18,7 +18,7 @@ import os import re import sys -from distutils.version import LooseVersion +from packaging.version import parse as parse_version from pathlib import Path, PurePosixPath from textwrap import indent from typing import Dict, List, Optional @@ -272,7 +272,7 @@ def _anim_md(anim, image_path, gallery_conf): thumb_size = gallery_conf["thumbnail_size"] use_dpi = round(min(t_s / f_s for t_s, f_s in zip(thumb_size, fig_size))) # FFmpeg is buggy for GIFs before Matplotlib 3.3.1 - if LooseVersion(matplotlib.__version__) >= LooseVersion("3.3.1") and FFMpegWriter.isAvailable(): + if parse_version(matplotlib.__version__) >= parse_version("3.3.1") and FFMpegWriter.isAvailable(): writer = "ffmpeg" elif ImageMagickWriter.isAvailable(): writer = "imagemagick"