[Python] Pyinstaller on MacOS: permissions given to .app bundle does not work

Discussão em 'Python' iniciado por Stack, Fevereiro 18, 2025.

  1. Stack

    Stack Membro Participativo

    Issue


    I recently built a Mac app with pyinstaller.
    However, the only way I can give permission to the app, is to give the permission to the executable file inside the .app bundle, while normal apps' permission is usually given to the .app bundle.

    May I know how could I make my app works like normal app? if you have any question, please let me know. Thank you for help.

    note: There is no info.plist inside the .app bundle

    To reproduce the problem:


    create environment:

    python -m venv venv
    . venv/bin/acticate
    pip install pyinstaller


    A python code that needs "input monitoring" permission:

    from pynput import keyboard
    import os

    def on_activate():
    os.system('say Global hotkey activated!')
    print('Global hotkey activated!')

    hotkey = keyboard.HotKey(
    keyboard.HotKey.parse('<cmd>+<shift>+2'),
    on_activate
    )

    def for_canonical(f):
    return lambda k: f(l.canonical(k))

    with keyboard.Listener(
    on_press=for_canonical(hotkey.press),
    on_release=for_canonical(hotkey.release)) as l:
    l.join()


    Build: pyinstaller main.py

    Continue reading...

Compartilhe esta Página