Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempted MacOS App build using Py2app #45

Open
KipTwitchell opened this issue Aug 30, 2022 · 1 comment
Open

Attempted MacOS App build using Py2app #45

KipTwitchell opened this issue Aug 30, 2022 · 1 comment

Comments

@KipTwitchell
Copy link
Member

I have attempted to build a MacOS app of tnz using py2app, but was not quite successful. I thought I'd give the results of my work, in case it's useful.

Here's the link to py2app

  1. I installed py2app on my machine using

pip3 install -U py2app

  1. I created a file called tnzMacOS.py with the following contents:
from distutils.core import setup

APP = ['setup.py']
DATA_FILES = []
OPTIONS = {
    'argv_emulation': True, 
    'site_packages': True,
    #'iconfile': 'appicon.icns',
    'plist': {
        'CFBundleName': 'tnz',
    }
}
setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)

  1. I built the app using the following command:

python3 tnzMacOS.py py2app

  1. There are various imports not found. I don't know enough to debug these:
Modules not found (unconditional imports):
 * _io._WindowsConsoleIO (importlib._bootstrap_external)
 * _overlapped (asyncio.windows_events)
 * _tkinter (tkinter)
 * com (com.sun.jna)
 * com.jna (com.sun)
 * com.sun (com.sun.jna.platform)
 * jinja2 (pkg_resources._vendor.pyparsing.diagram)
 * packaging (setuptools.config._validate_pyproject.formats)
 * pyparsing (pkg_resources._vendor.pyparsing.diagram)
 * railroad (pkg_resources._vendor.pyparsing.diagram)
 * setuptools.extern.jaraco (setuptools._entry_points, setuptools._reqs, setuptools.command.egg_info) [module alias]
 * setuptools.extern.jaraco.functools (setuptools._entry_points) [module alias]
 * setuptools.extern.jaraco.text (setuptools._entry_points, setuptools._reqs, setuptools.command.egg_info) [module alias]
 * setuptools.extern.more_itertools (setuptools._entry_points, setuptools._itertools, setuptools.dist) [module alias]
 * setuptools.extern.packaging (setuptools.config._apply_pyprojecttoml, setuptools.config.setupcfg, setuptools.depends, setuptools.dist, setuptools.extern.packaging, setuptools.wheel) [module alias]
 * setuptools.extern.packaging.requirements (setuptools.config.setupcfg) [module alias]
 * setuptools.extern.packaging.specifiers (setuptools.config.setupcfg) [module alias]
 * setuptools.extern.packaging.tags (setuptools.wheel) [module alias]
 * setuptools.extern.packaging.utils (setuptools.wheel) [module alias]
 * setuptools.extern.packaging.version (setuptools.command.egg_info, setuptools.config.setupcfg, setuptools.extern, setuptools.extern.packaging.requirements, setuptools.extern.packaging.specifiers, setuptools.extern.packaging.tags, setuptools.extern.packaging.utils, setuptools.extern.packaging.version) [module alias]
 * setuptools.extern.pyparsing (setuptools._vendor.packaging.markers, setuptools._vendor.packaging.requirements) [module alias]
 * trove_classifiers (setuptools.config._validate_pyproject.formats)
 * win32com (win32com)
 * win32com.shell (win32com.shell)
 * win32com.shellcon (win32com.shell)

Modules not found (conditional imports):
 * _manylinux (pkg_resources._vendor.packaging._manylinux, setuptools._vendor.packaging._manylinux)
 * com (pkg_resources._vendor.appdirs)
 * com.sun.jna (pkg_resources._vendor.appdirs)
 * com.sun.jna.platform (pkg_resources._vendor.appdirs)
 * importlib_metadata (setuptools._importlib)
 * pep517 (importlib.metadata)
 * setuptools.extern.more_itertools (setuptools._entry_points, setuptools._itertools, setuptools.dist) [module alias]
 * setuptools.extern.packaging.specifiers (setuptools.config.setupcfg) [module alias]
 * win32com (pkg_resources._vendor.appdirs)
 * win32com.shell (pkg_resources._vendor.appdirs)

Done!
  1. when I attempt to open the app using

~/tnz/dist/tnz.app/Contents/MacOS

I get the following output:

/Users/ktwitchell001/tnz/dist/tnz.app/Contents/MacOS/tnz ; exit;
ktwitchell001@Kips-MacBook-Pro ~ % /Users/ktwitchell001/tnz/dist/tnz.app/Contents/MacOS/tnz ; exit;
Traceback (most recent call last):
  File "/Users/ktwitchell001/tnz/dist/tnz.app/Contents/Resources/__boot__.py", line 527, in <module>
    _run()
  File "/Users/ktwitchell001/tnz/dist/tnz.app/Contents/Resources/__boot__.py", line 450, in _run
    exec(compile(source, path, "exec"), globals(), globals())
  File "/Users/ktwitchell001/tnz/dist/tnz.app/Contents/Resources/setup.py", line 9, in <module>
    from setuptools import setup
  File "setuptools/__init__.pyc", line 8, in <module>
  File "_distutils_hack/override.pyc", line 1, in <module>
  File "_distutils_hack/__init__.pyc", line 77, in do_override
  File "_distutils_hack/__init__.pyc", line 64, in ensure_local_distutils
AssertionError: /Users/ktwitchell001/tnz/dist/tnz.app/Contents/Resources/lib/python310.zip/distutils/core.pyc
2022-08-30 16:09:54.654 tnz[78496:1126837] Launch error
2022-08-30 16:09:54.654 tnz[78496:1126837] Launch error

Hope perhaps something there is useful

@najohnsn
Copy link
Member

najohnsn commented Sep 1, 2022

After taking a quick look at py2app, I don't believe you want to use the tnz setup.py, which is what I think APP = ['setup.py'] is doing. I think that the configuration your doing has similarities to the tnz setup.py. But in this case I think you want APP = ['tnz/zti.py'] ... which I think is similar to the tnz setup.py console_scripts entry_point zti=tnz.zti:main.

Also, you may need to include logging.json as a data file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants