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

If you have the ruamel.yaml library in your dependency, you will get an error when packing #530

Open
v3ucn opened this issue Jul 30, 2024 · 2 comments

Comments

@v3ucn
Copy link

v3ucn commented Jul 30, 2024

my setup.py:

import sys
sys.setrecursionlimit(5000)

import ruamel.yaml

from setuptools import setup

APP = ['webui.py']
DATA_FILES = []
OPTIONS = {

    'argv_emulation': False,
    'strip': False,  # 不去除debug信息
    'includes': ['gradio','ruamel.yaml'],

}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)
python3 setup.py py2app

it's print:

*** using recipe: detect_dunder_file *** {'packages': {'lightning_fabric', 'pandas', 'lightning', 'importlib_resources', 'torchgen', 'pytz', 'whisper', 'torio', 'multiprocess', 'dill', 'sklearn', 'tqdm', 'pytorch_lightning', 'modelscope', 'aliyunsdkcore', 'torchaudio', 'cffi', 'certifi', 'cosyvoice', 'altair', 'torchmetrics', 'matplotlib', 'numba', 'torch', 'websockets', 'numpy', 'pip', 'yapf_third_party', 'typer', 'dotenv', 'gradio', 'huggingface_hub', 'scipy', 'pydantic', 'librosa', 'jieba', 'ruamel', 'lightning_utilities', 'pyarrow', 'diffusers', 'sympy', 'gradio_client', 'Crypto', 'networkx', 'torchvision'}}

there's "ruamel" in the dict

got this error:

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/imp.py", line 300, in find_module
    raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named 'ruamel'

the thing is, there isn't a library named "ruamel", it's only "ruamel.yaml", need help guys, many thanks

@v3ucn
Copy link
Author

v3ucn commented Jul 30, 2024

just edit util.py to pass this bug:

def imp_find_module(name, path=None):
    """
    same as imp.find_module, but handles dotted names
    """
    names = name.split(".")
    print(names)

    if names == ['ruamel']:
        return (None, '/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ruamel', ('', '', 5))

    if path is not None:
        if isinstance(path, (str, unicode)):
            path = [os.path.realpath(path)]
    for name in names:
        # if name != "ruamel":
        result = imp.find_module(name, path)
        if result[0] is not None:
            result[0].close()
        path = [result[1]]
    print(result)
    return result

@jwojcik999
Copy link

jwojcik999 commented Aug 15, 2024

Did you try putting the yaml file inside the resources dict?

OPTIONS = {
    'argv_emulation': False,
    'strip': False,  # 不去除debug信息
    'includes': ['gradio'],
    'resources': ['ruamel.yaml'],
}

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