'The application “ ” can’t be opened. After extracting using zipfile in python macos

I'm unable to launch an application after using python to pull a build from a server and then extract. I get error message 'The application “ ” can’t be opened' Iv tried chmod +x on the executable in contents and then the application launches to a black screen. The same code seems to be working for me on windows. any ideas?

Heres my code

import glob, shutil, os, zipfile, send2trash

source = '/my/build/location'
target = '/my/directory'

def getLatestBuild(source, target):
    list_of_files = glob.glob(source + '/*.zip')
    latest_file = max(list_of_files, key = os.path.getctime)
    print(latest_file + '\n\nDownloading\n\n----------')
    shutil.copy(latest_file, target)
    return latest_file

def change_dir(latest_file):
    directory, file = os.path.split(latest_file)
    target_build = os.path.join(target, file)
    return target_build

def extractZip(target_build):
    zip_ref = zipfile.ZipFile(target_build, 'r')
    print('Unzipping' + target_build + '\n\n----------')
    zip_ref.extractall(target)
    print('file has been extracted\n\n---------')
    zip_ref.close()
    send2trash.send2trash(target_build)
    print(target_build + ' has been sent to trash')


latest_file = getLatestBuild(source, target)
target_build = change_dir(latest_file)
extractZip(target_build)


Solution 1:[1]

Appears the issue is down to symlinks being broken.

Normal extract

-rw-r--r--  1 daniel  staff    29B 22 Aug 17:36 QtConcurrent
-rw-r--r--  1 daniel  staff    26B 22 Aug 17:36 Resources
drwxr-xr-x  4 daniel  staff   136B 22 Aug 17:36 Versions

Python extract

lrwxr-xr-x  1 daniel  staff    29B 22 Aug 17:37 QtConcurrent -> Versions/Current/QtConcurrent
lrwxr-xr-x  1 daniel  staff    26B 22 Aug 17:37 Resources -> Versions/Current/Resources
drwxr-xr-x  4 daniel  staff   136B 22 Aug 17:37 Versions

Working as expected when extracting using standard OSX tool

    os.system("unzip -q -o %s -d %s" % (target_build, target))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1