| 1 |
# SPDX-License-Identifier: BSD-2-Clause |
| 2 |
|
| 3 |
# Copyright (c) 2024 Phil Thompson <[email protected]> |
| 4 |
|
| 5 |
|
| 6 |
import os |
| 7 |
import shutil |
| 8 |
|
| 9 |
from ..abstract_package import AbstractPackage |
| 10 |
from ..verbose import verbose |
| 11 |
|
| 12 |
|
| 13 |
# The directory containing the DLLs. |
| 14 |
_DLLS_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'dlls') |
| 15 |
|
| 16 |
|
| 17 |
class PyQt(AbstractPackage): |
| 18 |
""" The base PyQt package. """ |
| 19 |
|
| 20 |
def bundle_msvc_runtime(self, target_qt_dir, platform_tag): |
| 21 |
""" Bundle the MSVC runtime. """ |
| 22 |
|
| 23 |
verbose("Bundling the MSVC runtime") |
| 24 |
|
| 25 |
self._bundle_dlls(target_qt_dir, |
| 26 |
os.path.join(_DLLS_DIR, |
| 27 |
'msvc-64' if platform_tag == 'win_amd64' else 'msvc-32')) |
| 28 |
|
| 29 |
def bundle_openssl(self, target_qt_dir, openssl_dir, platform_tag): |
| 30 |
""" Bundle the OpenSSL DLLs. """ |
| 31 |
|
| 32 |
# Qt v6.2.0 and later include appropriate backends. |
| 33 |
if self.qt_version >= (6, 2, 0): |
| 34 |
verbose( |
| 35 |
"OpenSSL libraries are not required for Qt v6.2.0 and later") |
| 36 |
return |
| 37 |
|
| 38 |
if openssl_dir: |
| 39 |
verbose( |
| 40 |
"Bundling the OpenSSL libraries from '{0}'".format( |
| 41 |
openssl_dir)) |
| 42 |
else: |
| 43 |
verbose("Bundling the default OpenSSL libraries") |
| 44 |
|
| 45 |
openssl_dir = os.path.join(_DLLS_DIR, |
| 46 |
'openssl-64' if platform_tag == 'win_amd64' else 'openssl-32') |
| 47 |
|
| 48 |
self._bundle_dlls(target_qt_dir, openssl_dir) |
| 49 |
|
| 50 |
@staticmethod |
| 51 |
def _bundle_dlls(target_qt_dir, dlls_dir): |
| 52 |
""" Bundle the DLLs in a directory. """ |
| 53 |
|
| 54 |
bin_dir = os.path.join(target_qt_dir, 'bin') |
| 55 |
os.makedirs(bin_dir, exist_ok=True) |
| 56 |
|
| 57 |
for dll in os.listdir(dlls_dir): |
| 58 |
shutil.copy2(os.path.join(dlls_dir, dll), bin_dir) |