Skip to content

Commit

Permalink
Include markdown metadata to support entry-points
Browse files Browse the repository at this point in the history
  • Loading branch information
ovidner committed Oct 19, 2021
1 parent a0f30c4 commit d7fa545
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-markdown.py
Expand Up @@ -10,11 +10,19 @@
# 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')

# Markdown 3.3 introduced markdown.htmlparser submodule with hidden
# 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")
4 changes: 3 additions & 1 deletion src/_pyinstaller_hooks_contrib/tests/test_libraries.py
Expand Up @@ -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']))
""")
Expand Down

0 comments on commit d7fa545

Please sign in to comment.