ronaldoussoren / py2app

py2app is a Python setuptools command which will allow you to make standalone Mac OS X application bundles and plugins from Python scripts.
Other
342 stars 36 forks source link

Including homebrew installed apps? #468

Open ckcollab opened 1 year ago

ckcollab commented 1 year ago

Hey there!

Thanks so much for this project, overall has been a joy to work with.

One little hangup we're having is including "openslide.dylib"-type files. I've tried the following with some success, but is it still fails on my coworkers machine:

import glob

from setuptools import setup

APP = ['main.py']
DATA_FILES = [
    # Attaching OpenSlide dylib stuff..
    '/usr/local/lib/libopenslide.0.dylib',
]
OPTIONS = {
    'frameworks': [
        'libtiff.5.dylib',
    ]
}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=[
        'py2app',
        'openslide-python',
    ],
)

This gives the following error for my coworker:

Traceback (most recent call last):
  File "openslide/lowlevel.pyc", line 69, in <module>
  File "ctypes/__init__.pyc", line 452, in LoadLibrary
  File "ctypes/__init__.pyc", line 374, in __init__
OSError: dlopen(libopenslide.0.dylib, 0x0006): Symbol not found: _TIFFClientOpen
  Referenced from: /Users/elitrefts/Downloads/main.app/Contents/Resources/libopenslide.0.dylib
  Expected in: /Users/elitrefts/Downloads/main.app/Contents/Frameworks/libtiff.5.dylib

But we checked and libtiff.5.dylib exists in that location?! He's running an older version of Mac OSX than I am, I assume that binary is invalid for his older operating system? (12.1 for him vs. 12.6 for me)

Is there anyway to attach what we have with brew install openslide during our py2app packaging in a robust way? Maybe not..

ronaldoussoren commented 1 year ago

Interesting. I'm not sure what going on here. The error seems to indicate that py2app has correctly rewritten the load commands for libopenslide.0.dylib, but there's likely some other problem.

What happens if you remove the "frameworks" option, does this still copy libtiff into the application bundle?

ckcollab commented 1 year ago

OpenSlide and LibTiff seem like they are properly included with this setup:

❯ ls dist/main.app/Contents/Frameworks 
...
-rw-r--r--  1 eric  staff   201K Oct  2 12:32 libopenslide.0.dylib
...
-rw-r--r--  1 eric  staff   1.2M Oct  2 12:32 libtiff.5.dylib
...

Here's my latest settings:

import glob

from setuptools import setup

APP = ['main.py']
DATA_FILES = [
    ('deep_zoomer/static', glob.glob('deep_zoomer/static/*.*')),
    ('deep_zoomer/static/images', glob.glob('deep_zoomer/static/images/*.*')),
    ('deep_zoomer/templates', glob.glob('deep_zoomer/templates/*.*')),
    ('examples/', ['examples/SpekTrialImage.svs']),
]
OPTIONS = {
    'frameworks': [
        'libopenslide.0.dylib',
    ]
}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=[
        'py2app',
        'py-wsi',
        'openslide-python',
        'pywebview',
    ],
)

I'm asking my co-worker to test the build again to see if it runs fine on his computer. I assume same error as last time we tried, but I'll report back with results! To be clear this works fine on my machine with openslide installed via brew.

ckcollab commented 1 year ago

My co-worker reported back that the new build still isn't working :(