Skip to content

Commit

Permalink
hook: tensorflow: reformat line wrapping
Browse files Browse the repository at this point in the history
Use 120-character lines to reduce amount of line wrapping and make
the hook easier to read.
  • Loading branch information
rokm committed Dec 23, 2023
1 parent 5484aff commit fb6b7a2
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# ------------------------------------------------------------------

from PyInstaller.utils.hooks import is_module_satisfies, \
collect_submodules, collect_data_files
from PyInstaller.utils.hooks import (
collect_data_files,
collect_submodules,
is_module_satisfies,
)

tf_pre_1_15_0 = is_module_satisfies("tensorflow < 1.15.0")
tf_post_1_15_0 = is_module_satisfies("tensorflow >= 1.15.0")
Expand All @@ -31,11 +34,9 @@
"**/*.lib",
]

# Under tensorflow 2.3.0 (the most recent version at the time of writing),
# _pywrap_tensorflow_internal extension module ends up duplicated; once
# as an extension, and once as a shared library. In addition to increasing
# program size, this also causes problems on macOS, so we try to prevent
# the extension module "variant" from being picked up.
# Under tensorflow 2.3.0 (the most recent version at the time of writing), _pywrap_tensorflow_internal extension module
# ends up duplicated; once as an extension, and once as a shared library. In addition to increasing program size, this
# also causes problems on macOS, so we try to prevent the extension module "variant" from being picked up.
#
# See pyinstaller/pyinstaller-hooks-contrib#49 for details.
excluded_submodules = ['tensorflow.python._pywrap_tensorflow_internal']
Expand All @@ -47,24 +48,20 @@ def _submodules_filter(x):

if tf_pre_1_15_0:
# 1.14.x and earlier: collect everything from tensorflow
hiddenimports = collect_submodules('tensorflow',
filter=_submodules_filter)
hiddenimports = collect_submodules('tensorflow', filter=_submodules_filter)
datas = collect_data_files('tensorflow', excludes=data_excludes)
elif tf_post_1_15_0 and tf_pre_2_2_0:
# 1.15.x - 2.1.x: collect everything from tensorflow_core
hiddenimports = collect_submodules('tensorflow_core',
filter=_submodules_filter)
hiddenimports = collect_submodules('tensorflow_core', filter=_submodules_filter)
datas = collect_data_files('tensorflow_core', excludes=data_excludes)

# Under 1.15.x, we seem to fail collecting a specific submodule,
# and need to add it manually...
if tf_post_1_15_0 and tf_pre_2_0_0:
hiddenimports += \
['tensorflow_core._api.v1.compat.v2.summary.experimental']
hiddenimports += ['tensorflow_core._api.v1.compat.v2.summary.experimental']
else:
# 2.2.0 and newer: collect everything from tensorflow again
hiddenimports = collect_submodules('tensorflow',
filter=_submodules_filter)
hiddenimports = collect_submodules('tensorflow', filter=_submodules_filter)
datas = collect_data_files('tensorflow', excludes=data_excludes)

# From 2.6.0 on, we also need to explicitly collect keras (due to
Expand Down

0 comments on commit fb6b7a2

Please sign in to comment.