From c80196e3ad409eeecd25523c85ffcd1360f79773 Mon Sep 17 00:00:00 2001 From: Piotr R Date: Fri, 22 Oct 2021 14:14:24 +0200 Subject: [PATCH 1/2] Explicitly copy GSASII.libs and CFML.libs on Windows. #149 --- pyproject.toml | 1 + tools/Scripts/FreezeApp.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index c39a734a..05bc9c89 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -147,6 +147,7 @@ separator = { macos = ':', ubuntu = ':', windows = ';' } dir_suffix = { macos = '.app', ubuntu = '', windows = '' } content_suffix = { macos = 'Contents/MacOS/', ubuntu = '', windows = '' } libs = { macos = 'libsDarwin', ubuntu = 'libsLinux', windows = 'libsWin32' } +missing_calculator_libs = { macos = [], ubuntu = [], windows = ['GSASII.libs', 'CFML.libs'] } missing_pyside2_files = { macos = ['libshiboken2.abi3.*.dylib'], ubuntu = [], windows = ['shiboken2.abi3.dll', 'MSVCP140.dll'] } missing_pyside2_plugins = { macos = [], ubuntu = ['Qt/plugins/xcbglintegrations'], windows = [] } # EGL and GLX plugins missing_other_libraries = {macos = [], ubuntu = [], windows = ['libs/libiomp5md.dll', 'libs/opengl32.dll'] } diff --git a/tools/Scripts/FreezeApp.py b/tools/Scripts/FreezeApp.py index 3bfbfd5b..cdfc8e02 100755 --- a/tools/Scripts/FreezeApp.py +++ b/tools/Scripts/FreezeApp.py @@ -7,6 +7,7 @@ import os, sys import glob +import site import PySide2, shiboken2 import cryspy, GSASII import easyCore, easyDiffractionLib, easyApp @@ -43,6 +44,8 @@ def addedData(): for extra_file in extras: data.append({'from': extra_file, 'to': '.'}) + data = data + copyCalculators() + formatted = [] for element in data: formatted.append(f'--add-data={element["from"]}{separator}{element["to"]}') @@ -56,6 +59,22 @@ def appIcon(): icon_path = os.path.abspath(icon_path) return f'--icon={icon_path}' +def copyCalculators(): + missing_calculator_libs = CONFIG['ci']['pyinstaller']['missing_calculator_libs'][CONFIG.os] + data = [] + try: + message = 'Copy calculator libraries' + site_packages_path = site.getsitepackages()[1] + for lib_name in missing_calculator_libs: + lib_path = os.path.join(site_packages_path, lib_name) + data.append({'from': lib_path, 'to': lib_name}) + except Exception as exception: + Functions.printFailMessage(message, exception) + sys.exit(1) + + Functions.printSuccessMessage(message) + return data + def copyMissingLibs(): missing_files = CONFIG['ci']['pyinstaller']['missing_pyside2_files'][CONFIG.os] if len(missing_files) == 0: From 03eb2a0ee9d7d5db10998214249feae3ba08a7f9 Mon Sep 17 00:00:00 2001 From: Piotr R Date: Fri, 22 Oct 2021 14:22:34 +0200 Subject: [PATCH 2/2] getsitepackages() weirdness --- tools/Scripts/FreezeApp.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/Scripts/FreezeApp.py b/tools/Scripts/FreezeApp.py index cdfc8e02..baff86ea 100755 --- a/tools/Scripts/FreezeApp.py +++ b/tools/Scripts/FreezeApp.py @@ -64,7 +64,8 @@ def copyCalculators(): data = [] try: message = 'Copy calculator libraries' - site_packages_path = site.getsitepackages()[1] + # use the last element, since on certain conda installations we get more than one entry + site_packages_path = site.getsitepackages()[-1] for lib_name in missing_calculator_libs: lib_path = os.path.join(site_packages_path, lib_name) data.append({'from': lib_path, 'to': lib_name})