From d7fa5458622149d397973b9bc4cd530f3b80099b Mon Sep 17 00:00:00 2001 From: Olle Vidner Date: Tue, 19 Oct 2021 22:22:13 +0200 Subject: [PATCH] Include markdown metadata to support entry-points --- .../hooks/stdhooks/hook-markdown.py | 10 +++++++++- src/_pyinstaller_hooks_contrib/tests/test_libraries.py | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-markdown.py b/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-markdown.py index 3328fc4cc..f0a5628cb 100644 --- a/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-markdown.py +++ b/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-markdown.py @@ -10,7 +10,11 @@ # SPDX-License-Identifier: GPL-2.0-or-later # ------------------------------------------------------------------ -from PyInstaller.utils.hooks import is_module_satisfies, collect_submodules +from PyInstaller.utils.hooks import ( + collect_submodules, + copy_metadata, + is_module_satisfies, +) hiddenimports = collect_submodules('markdown.extensions') @@ -18,3 +22,7 @@ # dependency on html.parser if is_module_satisfies("markdown >= 3.3"): hiddenimports += ['html.parser'] + +# Extensions can be referenced by short names, e.g. "extra", through a mechanism +# using entry-points. Thus we need to collect the package metadata as well. +datas = copy_metadata("markdown") diff --git a/src/_pyinstaller_hooks_contrib/tests/test_libraries.py b/src/_pyinstaller_hooks_contrib/tests/test_libraries.py index 942917ec7..f1d927768 100644 --- a/src/_pyinstaller_hooks_contrib/tests/test_libraries.py +++ b/src/_pyinstaller_hooks_contrib/tests/test_libraries.py @@ -144,10 +144,12 @@ def test_pylint(pyi_builder): @importorskip('markdown') def test_markdown(pyi_builder): # Markdown uses __import__ed extensions. Make sure these work by - # trying to use the 'toc' extension.. + # trying to use the 'toc' extension, using both short and long format. pyi_builder.test_source( """ import markdown + print(markdown.markdown('testing', + extensions=['toc'])) print(markdown.markdown('testing', extensions=['markdown.extensions.toc'])) """)