Skip to content

Commit

Permalink
hookutils: qt: fix collection of QtWebEngineProcess helper ...
Browse files Browse the repository at this point in the history
... from Anaconda PySide2 package on Windows

When collecting `QtWebEngineProcess` helper from `PySide2`/`PySide6`
on Windows, always force the target collection directory to be the
PySide package directory (i.e., the relative target collection
directory should be `.`).

This ensures that the helper is collected in PyPI-wheel-compliant
location, even if the package is provided by Anaconda, where
the Qt `PrefixPath` is for example
`C:/Users/<user>/miniconda3/envs/<env-name>/Library`
and the corresponding `LibraryExecutablesPath` is
`C:/Users/<user>/miniconda3/envs/<env-name>/Library/bin`.

Thus, the auto-computed relative target collection directory would
be `bin`, but we need to match the PyPI wheel layout, where the
`LibraryExecutablesPath` is the same as the `PrefixPath`
(i.e., the PySide package directory).
  • Loading branch information
rokm committed Feb 20, 2024
1 parent 558cabb commit 503dc55
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 15 additions & 2 deletions PyInstaller/utils/hooks/qt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,8 +1141,9 @@ def collect_qtwebengine_files(self):

# Helper process executable (QtWebEngineProcess), located in ``LibraryExecutablesPath``.
# The target directory is determined as `LibraryExecutablesPath` relative to `PrefixPath`. On Windows,
# this should handle the differences between PySide2 and PySide6/PyQt5/PyQt6 PyPI wheel layout.
# this should handle the differences between PySide2/PySide6 and PyQt5/PyQt6 PyPI wheel layout.
rel_helper_path = os.path.relpath(self.location['LibraryExecutablesPath'], self.location['PrefixPath'])

# However, on Linux, we need to account for distribution-packaged Qt, where `LibraryExecutablesPath` might
# be nested deeper under `PrefixPath` than anticipated (w.r.t. PyPI wheel layout). For example, in Fedora,
# the helper is located under `/usr/lib64/qt5/libexec/QtWebEngineProcess`, with `PrefixPath` being `/usr`
Expand All @@ -1155,7 +1156,19 @@ def collect_qtwebengine_files(self):
rel_helper_path, "libexec"
)
rel_helper_path = "libexec"
dest = os.path.join(rel_data_path, rel_helper_path)

# Similarly, force the relative helper path for PySide2/PySide6 on Windows to `.`. This is already the case
# with PyPI PySide Windows wheels. But it is not the case with conda-installed PySide2, where the Qt's
# `PrefixPath` is for example `C:/Users/<user>/miniconda3/envs/<env-name>/Library`, while the corresponding
# `LibraryExecutablesPath` is `C:/Users/<user>/miniconda3/envs/<env-name>/Library/bin`.
if compat.is_win and not self.is_pyqt and rel_helper_path != ".":
logger.info(
"%s: overriding relative destination path of QtWebEngineProcess helper from %r to %r!", self,
rel_helper_path, "."
)
rel_helper_path = "."

dest = os.path.normpath(os.path.join(rel_data_path, rel_helper_path))
binaries.append((os.path.join(self.location['LibraryExecutablesPath'], 'QtWebEngineProcess*'), dest))

# The helper QtWebEngineProcess executable should have an accompanying qt.conf file that helps it locate the
Expand Down
4 changes: 4 additions & 0 deletions news/8314.bugfix.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(Windows) Fix collection of ``QtWebEngineProcess`` helper when
collecting ``PySide2`` and Qt installed via Anaconda on Windows.
The helper executable is now collected into top-level ``PySide2``
package directory, in order to match the PyPI wheel layout.

0 comments on commit 503dc55

Please sign in to comment.