PyInstaller 5.13.0 Restructured my MacOS app and breaks it

64 views
Skip to first unread message

Ankur Toshniwal

unread,
Aug 15, 2023, 4:59:01 AM8/15/23
to PyInstaller
It seems as though in a recent set of fixes, PyInstaller is attempting to structure macOS `.app` bundles correctly. (Code bundles are placed in Resources and Frameworks instead of MacOS). The bundle looks good, it has only the main executable in MacOS now as macOS bundles should. However...

It seems it broke everything because all the needed libs are now no longer in the same relative path as they used to be:

[17452] Error loading Python lib '/Users/ankurtoshniwal/pwr/thoughts/desktop_app/build/0.6.0a1/Project White Rabbit.app/Contents/MacOS/Python': dlopen: dlopen(/Users/ankurtoshniwal/pwr/thoughts/desktop_app/build/0.6.0a1/Project White Rabbit.app/Contents/MacOS/Python, 0x000A): tried: '/Users/ankurtoshniwal/pwr/thoughts/desktop_app/build/0.6.0a1/Project White Rabbit.app/Contents/MacOS/Python' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/ankurtoshniwal/pwr/thoughts/desktop_app/build/0.6.0a1/Project White Rabbit.app/Contents/MacOS/Python' (no such file), '/Users/ankurtoshniwal/pwr/thoughts/desktop_app/build/0.6.0a1/Project White Rabbit.app/Contents/MacOS/Python' (no such file)


Saving session...completed.


[Process completed]

My spec file is:

```

# -*- mode: python ; coding: utf-8 -*-
import inspect
import os
import sys ; sys.setrecursionlimit(sys.getrecursionlimit() * 5)

import PySide6
import _pyinstaller_hooks_contrib

# Allow us to import from `core`
sys.path.append(".")

from core import __app_name__, __version__

block_cipher = None

community_hooks_path = os.path.dirname(inspect.getfile(_pyinstaller_hooks_contrib))

pyside6_path = os.path.dirname(inspect.getfile(PySide6))

a = Analysis(
    ['./ProjectWhiteRabbit.py'],
    pathex=[os.path.abspath(".")],
    datas=[
        ("./*.traineddata", "."),
        ("./gui/img", "./gui/img"),
        ("./gui/fonts", "./gui/fonts"),
        ("./alembic.ini", "."),
        ("./migrations", "./migrations"),
        ("./scripts", "./scripts"),
    ],
    hiddenimports=[
        "sqlalchemy.sql.default_comparator",
        "sklearn.metrics._pairwise_distances_reduction._middle_term_computer",
        "sklearn.metrics._pairwise_distances_reduction._datasets_pair",
        "tiktoken_ext",
        "tiktoken_ext.openai_public",
    ],
    hookspath=[
        os.path.join(community_hooks_path, "hooks/stdhooks")
    ],
    runtime_hooks=[],
    win_no_prefer_redirects=False,
    win_private_assemblies=False,
    cipher=block_cipher,
    noarchive=False
)

pyz = PYZ(
    a.pure,
    a.zipped_data,
    cipher=block_cipher
)

exe = EXE(
    pyz,
    a.scripts,
    [],
    exclude_binaries=True,
    name=__app_name__,
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    target_arch='x86_64',
    console=False
)

coll = COLLECT(
    exe,
    a.binaries,
    a.zipfiles,
    a.datas,
    strip=False,
    upx=True,
    upx_exclude=[],
    name=__app_name__
)

app = BUNDLE(
    coll,
    name=f'{__app_name__}.app',
    icon='ProjectWhiteRabbit.icns',
    bundle_identifier='builders.pwr',
    info_plist={
        "NSPrincipalClass": "NSApplication",
        "NSAppleScriptEnabled": False,
        'CFBundleName': __app_name__,
        'CFBundleDisplayName': __app_name__,
        'CFBundleVersion': __version__,
        'CFBundleShortVersionString': __version__,
        'CFBundleTypeIconFiles': ['ProjectWhiteRabbit.icns'],
        'NSHighResolutionCapable': True,
        # This makes the app appearance match the current theme in Mac
        # rather than always being light theme
        "NSRequiresAquaSystemAppearance": True,
        "NSAppleEventsUsageDescription": "Access to apple events allows PWR to be accessible through system wide shortcuts."
    }
)

```

I'm not too sure how to proceed here, but I can share our `.spec` file as well.

Anyone else facing this issue? Would appreciate a hand here! I can share more and discuss this if anyone is familiar. My company depends on it *grimmacing*

Thanks in advance,

Ankur

Ankur Toshniwal

unread,
Aug 15, 2023, 2:01:50 PM8/15/23
to PyInstaller
I reverted to `5.12.0` and the can now be built in a working way

bwoodsend

unread,
Aug 16, 2023, 4:49:28 AM8/16/23
to PyInstaller
Are you using unreleased PyInstaller from GitHub? If so, it looks like you need to recompile the bootloaders.

Ankur Toshniwal

unread,
Aug 16, 2023, 5:15:48 AM8/16/23
to PyInstaller
Do you recommend starting here and building the bootloader myself?
https://pyinstaller.org/en/latest/bootloader-building.html

Ankur Toshniwal

unread,
Aug 16, 2023, 5:15:54 AM8/16/23
to PyInstaller
Indeed I'm using the `develop` branch on github: https://github.com/pyinstaller/pyinstaller/tags. I just reverted to tag 5.12.0. The currently released version of pyinstaller (`master`) is also broken for us since we have multiple dependencies that rely on C++ extensions in their wheels and were just not working properly on `master`.

My `poetry.toml`:
```
[tool.poetry.dependencies]
python = "3.9.16"
Pillow = "^8.3.0"
imutils = "^0.5.4"
Flask = "*"
google = "^3.0.0"
protobuf = "^3.17.3"
fuzzysearch = "^0.7.3"
python-Levenshtein = "^0.12.2"
importlib-metadata = "^4.6.1"
numpy = "^1.21.0"
ImageHash = "^4.2.0"
requests = "^2.25.1"
click = "^8.0.1"
SQLAlchemy = "1.4.43"
alembic = "^1.6.5"
fuzzywuzzy = "^0.18.0"
lxml = "^4.6.3"
cssselect = "^1.1.0"
PySide6 = "6.4.0"
beautifulsoup4 = "^4.10.0"
superqt = "^0.2.5"
gevent = "^21.12.0"
python-engineio = "3.13.2"
Werkzeug = "2.0.1"
jsonschema = "^4.9.1"
mixpanel = "^4.10.0"
sentry-sdk = "^1.9.9"
pyobjc = "^8.5.1"
appdirs = "^1.4.4"
python-dotenv = "^1.0.0"
openai = "^0.27.2"
tiktoken = "^0.3.3"
scikit-learn = "^1.2.2"
simhash = "^2.1.2"
```

On Wednesday, August 16, 2023 at 4:49:28 AM UTC-4 bwoodsend wrote:
Reply all
Reply to author
Forward
0 new messages