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

Add work-around for tensorflow < 2.3.0 trying to use site.USER_SITE #546

Merged
merged 1 commit into from
Feb 13, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions news/546.update.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Add work-around for ``tensorflow`` < 2.3.0 trying to use
``site.USER_SITE``, which is ``None`` in PyInstaller 5.5 and later
due to removal of PyInstaller's fake ``site`` module.
1 change: 1 addition & 0 deletions src/_pyinstaller_hooks_contrib/hooks/rthooks.dat
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
'pythoncom': ['pyi_rth_pythoncom.py'],
'pyqtgraph': ['pyi_rth_pyqtgraph_multiprocess.py'],
'pywintypes': ['pyi_rth_pywintypes.py'],
'tensorflow': ['pyi_rth_tensorflow.py'],
}
19 changes: 19 additions & 0 deletions src/_pyinstaller_hooks_contrib/hooks/rthooks/pyi_rth_tensorflow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#-----------------------------------------------------------------------------
# Copyright (c) 2023, PyInstaller Development Team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#
# SPDX-License-Identifier: Apache-2.0
#-----------------------------------------------------------------------------

# `tensorflow` versions prior to 2.3.0 attempt to use `site.USER_SITE` in path/string manipulation functions.
# As frozen application runs with disabled `site`, the value of this variable is `None`, and causes path/string
# manipulation functions to raise an error. As a work-around, we set `site.USER_SITE` to an empty string, which is
# also what the fake `site` module available in PyInstaller prior to v5.5 did.
import site

if site.USER_SITE is None:
site.USER_SITE = ''