Cannot build Mac app with pygame and pyinstaller

193 views
Skip to first unread message

Irv Kalb

unread,
Mar 24, 2023, 3:15:25 AM3/24/23
to pyins...@googlegroups.com
I'm trying to build a larger application on my Mac and am getting errors.  So, I tried using a minimal test program and I'm still getting the same errors:

Mac Ventura 13.0.1
Python 3.11.1
pygame-ce 2.1.4 (latest fork of pygame)
PyInstaller 5.9.0

Here is my test program which runs file (using PyCharm or IDLE):

import pygame
from pygame.locals import *
import sys

BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
WINDOW_WIDTH = 640
WINDOW_HEIGHT = 480
FRAMES_PER_SECOND = 30

pygame.init()
window = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))
clock = pygame.time.Clock()
 
while True:
    for event in pygame.event.get():
 
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
    
    window.fill(BLACK)    
    pygame.draw.circle(window, WHITE, (WINDOW_WIDTH // 2, WINDOW_HEIGHT // 2), 60, 0) 
    pygame.display.update()
    clock.tick(FRAMES_PER_SECOND)

I'm using the following spec file (because that's how I'm building my larger app):

# -*- mode: python ; coding: utf-8 -*-


block_cipher = None

a = Analysis(
    ['Main_Test.py'],
    pathex=[],
    binaries=[],
    datas=[],
    hiddenimports=[],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    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,
    a.binaries,
    a.zipfiles,
    a.datas,
    [],
    name='Main_Test',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=True,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)

And this is what I see when I try to run the resulting file in dist folder:

[5196] Error loading Python lib '/var/folders/x3/tfnjhmt16n9dcyz2r3b5g8780000gn/T/_MEIJnOC6Y/Python': dlopen: dlopen(/var/folders/x3/tfnjhmt16n9dcyz2r3b5g8780000gn/T/_MEIJnOC6Y/Python, 0x000A): tried: '/var/folders/x3/tfnjhmt16n9dcyz2r3b5g8780000gn/T/_MEIJnOC6Y/Python' (code signature invalid in <41AEFAB3-E30A-3AED-806A-AC88734A771B> '/private/var/folders/x3/tfnjhmt16n9dcyz2r3b5g8780000gn/T/_MEIJnOC6Y/Python' (errno=1) sliceOffset=0x00004000, codeBlobOffset=0x006BBFC0, codeBlobSize=0x0001A950), '/System/Volumes/Preboot/Cryptexes/OS/var/folders/x3/tfnjhmt16n9dcyz2r3b5g8780000gn/T/_MEIJnOC6Y/Python' (no such file), '/var/folders/x3/tfnjhmt16n9dcyz2r3b5g8780000gn/T/_MEIJnOC6Y/Python' (code signature invalid in <41AEFAB3-E30A-3AED-806A-AC88734A771B> '/private/var/folders/x3/tfnjhmt16n9dcyz2r3b5g8780000gn/T/_MEIJnOC6Y/Python' (errno=1) sliceOffset=0x00004000, codeBlobOffset=0x006BBFC0, codeBlobSize=0x0001A950), '/private/var/folders/x3/tfnjhmt16n9dcyz2r3b5g8780000gn/T/_MEIJnOC6Y/Python' (code signature invalid in <41AEFAB3-E30A-3AED-806A-AC88734A771B> '/private/var/folders/x3/tfnjhmt16n9dcyz2r3b5g8780000gn/T/_MEIJnOC6Y/Python' (errno=1) sliceOffset=0x00004000, codeBlobOffset=0x006BBFC0, codeBlobSize=0x0001A950), '/System/Volumes/Preboot/Cryptexes/OS/private/var/folders/x3/tfnjhmt16n9dcyz2r3b5g8780000gn/T/_MEIJnOC6Y/Python' (no such file), '/private/var/folders/x3/tfnjhmt16n9dcyz2r3b5g8780000gn/T/_MEIJnOC6Y/Python' (code signature invalid in <41AEFAB3-E30A-3AED-806A-AC88734A771B> '/private/var/folders/x3/tfnjhmt16n9dcyz2r3b5g8780000gn/T/_MEIJnOC6Y/Python' (errno=1) sliceOffset=0x00004000, codeBlobOffset=0x006BBFC0, codeBlobSize=0x0001A950)

logout


Saving session...

...copying shared history...

...saving history...truncating history files...

...completed.


I have no idea what any of the above means or what to do to try to fix it.  Any help would be appreciated.

FYI:  The exact same files build just fine on Windows.

Jasper Harrison

unread,
Mar 27, 2023, 4:32:58 AM3/27/23
to pyins...@googlegroups.com
Irv

It looks like the issue is something to do with MacOS codesigning. I would suggest you have a bit of a search around in our bug tracker and see if there's a solution there (documentation improvements on this will be coming soon!) and if not, then open an issue there where one of the other developers, who are more versed in the fun nuances of MacOS codesigning can assist you.

Jasper Harrison, aka Legorooj
Core Developer on PyInstaller

------- Original Message -------
--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyinstaller...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/31CCB60F-D740-40BD-AA3D-F9E360F88870%40gmail.com.

publickey - legorooj@protonmail.com - 0x164CF234.asc
signature.asc
Reply all
Reply to author
Forward
0 new messages