Skip to content

Commit

Permalink
hooks: add hook for backports namespace package
Browse files Browse the repository at this point in the history
Add hook for `backports` package, to accommodate the `pkgutil`-style
`backports` namespace package provided by `backports.functools-lru-cache`
and the latest release of `backports.tarfile`.

The `__init__.py` file from this `backports` namespace package uses
`__import('pkgutil')__`, which slips past PyInstaller's modulegraph
analysis, hence we need a hidden import.
  • Loading branch information
rokm committed Apr 23, 2024
1 parent 485ce07 commit 6d9f5c5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions news/735.new.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Add hook for ``backports`` package, to accommodate the ``pkgutil``-style
``backports`` namespace package provided by ``backports.functools-lru-cache``
and the latest release of ``backports.tarfile``.
20 changes: 20 additions & 0 deletions src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-backports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# ------------------------------------------------------------------
# Copyright (c) 2024 PyInstaller Development Team.
#
# This file is distributed under the terms of the GNU General Public
# License (version 2.0 or later).
#
# The full license is available in LICENSE.GPL.txt, distributed with
# this software.
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ------------------------------------------------------------------

# Some of jaraco's backports packages (backports.functools-lru-cache, backports.tarfile) use pkgutil-style `backports`
# namespace package, with `__init__.py` file that contains:
#
# __path__ = __import__('pkgutil').extend_path(__path__, __name__)
#
# This import via `__import__` function slips past PyInstaller's modulegraph analysis; so add a hidden import, in case
# the user's program (and its dependencies) have no other direct imports of `pkgutil`.
hiddenimports = ['pkgutil']

0 comments on commit 6d9f5c5

Please sign in to comment.