Skip to content
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

Include markdown metadata to support entry-points #336

Merged
merged 1 commit into from Oct 20, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions news/336.update.rst
@@ -0,0 +1 @@
Update ``markdown`` hook to include package metadata, enabling the use of short names for built-in extensions, such as ``extra`` or ``toc``.
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