8wDlpd.png
8wDFp9.png
8wDEOx.png
8wDMfH.png
8wDKte.png

用于为 macOS 生成捆绑包的这个 `.spec` 文件有什么问题?

Safiul Alam 2月前

29 0

我正在尝试为这个项目生成一个适用于 macOS 的软件包。存储库中的 .spec 文件在 Windows 上运行良好,但当我尝试将其用于 macOS 时,它失败了。我已尝试通过以下方式修复 MacOS 版本

我正在尝试为 这个项目 .spec 存储库中的文件在 Windows 上运行良好,但当我尝试将其用于 macOS 时,它失败了。

我尝试通过修改它来修复 MacOS 的问题,结果如下:

# -*- mode: python ; coding: utf-8 -*-
import os.path
from pathlib import Path
from PyInstaller.compat import is_darwin, is_win
from PyInstaller.utils.hooks import copy_metadata, collect_data_files, collect_all


datas = []

datas += collect_data_files("transformers", include_py_files=True)
datas += collect_data_files("lightning")
datas += collect_data_files("lightning_fabric")
datas += collect_data_files("speechbrain")
datas += collect_data_files("pyannote")
datas += collect_data_files("asteroid_filterbanks")
datas += collect_data_files("whisperx")
datas += collect_data_files("librosa")

datas += copy_metadata("tqdm")
datas += copy_metadata("regex")
datas += copy_metadata("requests")
datas += copy_metadata("packaging")
datas += copy_metadata("filelock")
datas += copy_metadata("numpy")
datas += copy_metadata("tokenizers")
datas += copy_metadata("pillow")
datas += copy_metadata("huggingface_hub")
datas += copy_metadata("safetensors")
datas += copy_metadata("pyyaml")

datas += [("res", "res")]
datas += [("config.ini", ".")]
datas += [(".env", ".")]
datas += [("venv/lib/python3.10/site-packages/customtkinter", "customtkinter")]
datas += [("venv/lib/python3.10/site-packages/torch", "torch")]
datas += [("venv/lib/python3.10/site-packages/torchgen", "torchgen")]
datas += [("venv/lib/python3.10/site-packages/speech_recognition", "speech_recognition")]
datas += [("venv/lib/python3.10/site-packages/moviepy", "moviepy")]
datas += [("venv/lib/python3.10/site-packages/dotenv", "dotenv")]
datas += [("venv/lib/python3.10/site-packages/openai", "openai")]

hiddenimports = [
    "huggingface_hub.repository",
    "pytorch",
    "sklearn.utils._cython_blas",
    "sklearn.neighbors.typedefs",
    "sklearn.neighbors.quad_tree",
    "sklearn.tree",
    "sklearn.tree._utils",
    "darkdetect",
    "tkinter.font",
    "tkinter.ttk",
    "cmath",
    "pickletools",
    "unittest.mock",
    "aifc",
    "proglog",
    "imageio",
    "decorator",
]

block_cipher = None

debug = True
if debug:
    options = [("v", None, "OPTION")]
else:
    options = []

a = Analysis(
    ["src/app.py"],
    pathex=[],
    binaries=[],
    datas=datas,
    hiddenimports=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)

macos_icon = "res/macos/icon.icns"
windows_icon = "res/windows/icon.ico"

exe = EXE(
    pyz,
    a.scripts,
    options,
    exclude_binaries=True, #NEW
    name="Audiotext",
    debug=debug,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=debug,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file="res/macos/entitlements.plist" if is_darwin else None,
    icon=windows_icon if is_win else macos_icon,
)

coll = COLLECT(
    exe,
    a.binaries,
    a.zipfiles,
    a.datas,
    strip=False,
    upx=True,
    upx_exclude=[],
    name="Audiotext",
)

app = BUNDLE(
    coll,
    name="Audiotext.app",
    icon=macos_icon,
    bundle_identifier="com.henestrosadev.audiotext",
    version="2.3.0",
    info_plist={
        "NSPrincipalClass": "NSApplication",
        "NSAppleScriptEnabed": False,
        "NSHighResolutionCapable": True,
        "NSMicrophoneUsageDescription": "Allow Audiotext to record audio from your microphone to generate transcriptions.",
    }
)

现在,它生成了包,但是当我打开生成的文件时,我总是得到一个 ModuleNotFoundError 。例如,我现在遇到的错误是 ModuleNotFoundError: No module named 'openai' 。我通过添加此行修复了它,就像我对之前缺失的其余模块所做的那样:

datas += [("venv/lib/python3.10/site-packages/openai", "openai")]

现在,我得到的错误是 ModuleNotFoundError: No module named 'pydantic' 。有些地方不对劲,因为手动添加程序的所有包是没有意义的。

帖子版权声明 1、本帖标题:用于为 macOS 生成捆绑包的这个 `.spec` 文件有什么问题?
    本站网址:http://xjnalaquan.com/
2、本网站的资源部分来源于网络,如有侵权,请联系站长进行删除处理。
3、会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。
4、本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
5、站长邮箱:yeweds@126.com 除非注明,本帖由Safiul Alam在本站《macos》版块原创发布, 转载请注明出处!
最新回复 (0)
返回
作者最近主题: