Skip to content

Commit

Permalink
Add work-around for ffpyplayer trying to use site.USER_BASE
Browse files Browse the repository at this point in the history
Add a run-time hook for `ffpyplayer` that sets `site.USER_BASE` to
an empty string, in order to prevent run-time errors caused by
`ffpyplayer` blindly passing `site.USER_BASE` to `os.path.join`.

Due to `site` being disabled in PyInstaller-frozen application,
`site.USER_BASE` is `None`. In PyInstaller versions prior to v5.5,
this was mitigated by PyInstaller's own fake `site` module, which
also set `site.USER_BASE` to an empty string.
  • Loading branch information
rokm committed Feb 13, 2023
1 parent 63d24c3 commit 36d6811
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions news/545.update.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Add work-around for ``ffpyplayer`` 4.3.5 and 4.4.0 trying to use
``site.USER_BASE``, 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
@@ -1,5 +1,6 @@
{
'enchant': ['pyi_rth_enchant.py'],
'ffpyplayer': ['pyi_rth_ffpyplayer.py'],
'osgeo': ['pyi_rth_osgeo.py'],
'traitlets': ['pyi_rth_traitlets.py'],
'usb': ['pyi_rth_usb.py'],
Expand Down
19 changes: 19 additions & 0 deletions src/_pyinstaller_hooks_contrib/hooks/rthooks/pyi_rth_ffpyplayer.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
#-----------------------------------------------------------------------------

# Starting with v4.3.5, the `ffpyplayer` package attempts to use `site.USER_BASE` in path manipulation functions.
# As frozen application runs with disabled `site`, the value of this variable is `None`, and causes path manipulation
# functions to raise an error. As a work-around, we set `site.USER_BASE` 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_BASE is None:
site.USER_BASE = ''

0 comments on commit 36d6811

Please sign in to comment.