Kenshin9977 / video-dl

A GUI for yt-dlp that aims to simplify its usage.
MIT License
37 stars 7 forks source link

build successful on M1 Chip Macbook Pro, but cant open app (icon keep jumping on dock, no app windows shows up) #15

Open ghost opened 2 years ago

ghost commented 2 years ago

build successful on M1 Chip Macbook Pro, but cant open app (icon keep jumping on dock, no app windows shows up) Kapture 2022-08-26 at 15 18 20

Everthing fine while building via sudo python3 MACOS-video-dl.py py2app but following warnings

Modules not found (conditional imports):
 * Crypto.Cipher (yt_dlp.extractor.bilibili, yt_dlp.extractor.ivi)
 * Crypto.Hash (yt_dlp.extractor.ivi)
 * Crypto.PublicKey (yt_dlp.extractor.bilibili)
 * MacOS (Cython.Plex.Timing)
 * Numeric (numpy.distutils.system_info)
 * OpenSSL.crypto (urllib3.contrib.pyopenssl)
 * Parser (Cython.Compiler.Main)
 * Queue (urllib3.util.queue)
 * StringIO (Cryptodome.Util.py3compat, urllib3.packages.six)
 * _dummy_thread (cffi.lock, future.backports.misc)
 * _manylinux (pkg_resources._vendor.packaging.tags)
 * _pytest (numpy.typing.tests.test_typing)
 * _ufunc (numpy._typing)
 * anydbm (future.moves.dbm)
 * array_interface_testing (numpy.core.tests.test_array_interface)
 * cPickle (pycparser.ply.yacc)
 * ccompiler_opt (numpy.distutils.tests.test_ccompiler_opt, numpy.distutils.tests.test_ccompiler_opt_conf)
 * checks (numpy.core.tests.test_cython)
 * com (pkg_resources._vendor.appdirs)
 * com.sun.jna (pkg_resources._vendor.appdirs)
 * com.sun.jna.platform (pkg_resources._vendor.appdirs)
 * cryptography (requests)
 * cryptography.x509.extensions (urllib3.contrib.pyopenssl)
 * dj_database_url (environs)
 * dj_email_url (environs)
 * django_cache_url (environs)
 * dl (setuptools.command.build_ext)
 * dumbdbm (future.moves.dbm.dumb)
 * dummy_thread (cffi.lock, future.backports.misc)
 * future_builtins (future.builtins.misc)
 * gdbm (future.moves.dbm.gnu)
 * graphviz (ffmpeg._view)
 * importlib_metadata (PyInstaller.compat, PyInstaller.utils.hooks.conda, click.decorators)
 * mem_policy (numpy.core.tests.test_mem_policy)
 * nose (numpy.testing._private.decorators, numpy.testing._private.utils, numpy.testing.tests.test_doctesting)
 * nose.plugins (numpy.testing._private.nosetester)
 * nose.plugins.builtin (numpy.testing._private.nosetester)
 * numarray (numpy.distutils.system_info)
 * numpy.testing.noseclasses ()
 * numpy_distutils (numpy.f2py.diagnose)
 * numpy_distutils.command.build_flib (numpy.f2py.diagnose)
 * numpy_distutils.command.cpuinfo (numpy.f2py.diagnose)
 * numpy_distutils.cpuinfo (numpy.f2py.diagnose)
 * numpy_distutils.fcompiler (numpy.f2py.diagnose)
 * pep517 (importlib.metadata)
 * psutil (numpy.testing._private.utils)
 * pycryptodome_test_vectors (Cryptodome.SelfTest.Hash.test_BLAKE2)
 * pygments (Cython.Compiler.Annotate)
 * pygments.formatters (Cython.Compiler.Annotate)
 * pygments.lexers (Cython.Compiler.Annotate)
 * pytest (numpy._pytesttester, numpy.testing._private.utils)
 * scipy (numpy.testing._private.nosetester)
 * simplejson (requests.compat)
 * thread (cffi.cparser, cffi.lock, future.backports.misc)
 * whichdb (future.moves.dbm)
 * win32com (pkg_resources._vendor.appdirs)
 * win32com.shell (pkg_resources._vendor.appdirs)
 * win32pdh (numpy.testing._private.utils)

Done!
Kenshin9977 commented 2 years ago

Have you installed the requirements? If not, first create a virtual env if it's not already done: python3 -m venv venv --upgrade-deps source ./venv/bin/activate Then enter the following commands: pip install pip-tools pip-compile --upgrade requirements.in pip install -r requirements.txt

Then retry to build with python3 MACOS-video-dl.py py2app

ghost commented 2 years ago

I followed the above steps. Like the results I compiled myself, I also compiled it successfully with your steps, but the result is still the same as before. The icon keeps beating, but the application window does not appear, and there is no window prompting permissions or anything else.

Kenshin9977 commented 2 years ago

The warnings are the same? If you only want to use the program, I just uploaded a .dmg in the latest release. You'll need to disable .dmg's verification as it's currently no signed with an Apple compatible certificate: https://www.macworld.com/article/672947/how-to-open-a-mac-app-from-an-unidentified-developer.html

ghost commented 2 years ago

I downloaded the dmg you uploaded. With the same problem, the icon keeps beating and the app can't start.

In addition, I forked this repository and ran the building workflow with github action to get an x64 application for macos, which could not start either.

Kenshin9977 commented 2 years ago

Can you try with the latest version?

ghost commented 2 years ago

tried the latest release and the icon keeps beating on dock, issue is still not solved

ghost commented 1 year ago

i think i found the reason why app not running on macOS

first run sudo pyinstaller -D app.py

second run ./dist/app/app

it gives error below

Mac OS Version is 13.0.1 and patch enabled so applying the patch
Applyting Mac OS 12.3+ Alpha Channel fix.  Your default Alpha Channel is now 0.99
Traceback (most recent call last):
  File "app.py", line 13, in <module>
  File "updater/updater.py", line 43, in __init__
  File "updater/updater.py", line 137, in _get_versions_json
PermissionError: [Errno 13] Permission denied: 'versions.zip'
[6557] Failed to execute script 'app' due to unhandled exception!

so there is some permission issue when running the app

thrid run 'sudo ./dist/app/app', app works, and sould use sudo every time of running the app binary, or if copy all contents in app directory to a new created floder outside the project folder, and run ./app it does not need sudo 截屏2022-12-10 15 54 18

if pack a standalone app for mac by sudo pyinstaller -D -w app.py it will crash quit after double click the app icon, should be the reason showed above.

so how to solve this PermissionError: [Errno 13] Permission denied: 'versions.zip' , there is no such file in app directory.

ghost commented 1 year ago

i commented code related to updater in app.py

#from updater.updater import Updater
from videodl_logger import videodl_logger

logger = logging.getLogger()

if __name__ == "__main__":
    fire.Fire(videodl_logger)
    #Updater().update_app()
    logger.debug("GUI's startup")
    video_dl_gui()

and pack via run sudo pyinstaller -D app.py and then run binary ./dist/app/app this time there is no need for sudo

but pack into standalone macOS app still crashes

ghost commented 1 year ago

it seems the confilct between pysimplegui and pyinstaller, and no proper solution found yet.

instead, i have to create setup.py and use pip install way to install this app as a package into my bin directory

here is my setup.py beside app.py

# -*- coding: utf-8 -*-
from pathlib import Path
from setuptools import setup, find_packages

def get_packages(package):
    """
    Return root package and all sub-packages.
    """
    return [str(path.parent) for path in Path(package).glob("**/__init__.py")]

try:
    long_description = open("README.rst").read()
except IOError:
    long_description = "Video Downloader"

setup(
    name="video-dl",
    version="0.11.0",
    description="Video Downloader",
    long_description=long_description,
    license="MIT",
    author="Kenshin",
    author_email="unknown",
    url="https://github.com/Kenshin9977/video-dl",
    packages=['', 'utils', 'components_handlers', 'updater'],
    package_data={'': ['*.ini', '*.ico', '*.png']},
    python_requires='>=3.10',
    install_requires=[
        'boto3',
        'black',
        'environs',
        'fire',
        'flake8',
        'gputil',
        'mergedeep',
        'pillow',
        'pyinstaller',
        'pynacl',
        'pysimplegui',
        'quantiphy',
        'requests',
        'yt-dlp',
    ],
    entry_points={"console_scripts": ["video-dl=gui:main"]},
    classifiers=[
        "Programming Language :: Python",
        "Programming Language :: Python :: 3.10",
    ]
)

and input following to the bottom of gui.py

def main():
    import __main__
    video_dl_gui()

if __name__ == "__main__":
    main()

then run python setup.py sdist after that go to dist folder showed up and run pip install video-dl-0.11.0.tar.gz

now i can run package video-dl in any terminal window and run it, not perfect, but better than run python script