py2app setup.py使用问题

发布于 2024-12-02 14:40:58 字数 1320 浏览 2 评论 0原文

好的,我正在尝试使用 py2app 为我的项目生成发行版。我仍然不确定我是否掌握了它的窍门。所以我的 setup.py 看起来像这样:

"""
This is a setup.py script generated by py2applet

Usage:
    python setup.py py2app
"""

from setuptools import setup
import setuptools

PACKAGES = ['sqlalchemy.dialects.sqlite']
MODULES = ['sqlite3']

APP = ['tvb/interfaces/web/run.py']
OPTIONS = {'argv_emulation': True,
           'packages': PACKAGES ,
           'includes' : MODULES }
DATA_FILES = []

setup(
    app=APP,
    data_files=DATA_FILES,
    packages = setuptools.find_packages(), 
    include_package_data=True,
    options={'py2app': OPTIONS},
    setup_requires=['py2app', "pyopengl", "cherrypy", "sqlalchemy", "simplejson", 
                          "formencode", "genshi", "quantities","numpy", "scipy",
                          "numexpr", "nibabel", "cfflib", "mdp", "apscheduler",
                          "scikits.learn"]
)

所以我的第一个问题是:我应该在 py2app 的模块中包含什么? py2app 是否知道扫描 setup_requires 中的内容并包含它们,或者我是否需要在 MODULES 中为它们添加一些条目?

另一个问题是,我在尝试运行我的应用程序时遇到:sqlalchemy.exc.ArgumentError:无法确定“sqlite”的方言。经过大量谷歌搜索后,我只看到对于 py2exe,您需要将 sqlalchemy.dialects.sqlite 作为包包含在内,但它似乎对我不起作用。我在这里错过了什么吗?

最后一个是我在 python setup.py py2app 之前得到一个:格式错误的对象(加载命令 3 cmdsize 不是 8 的倍数)。这是正常的吗?

问候, 博格丹

Ok so I'm trying to use py2app to generate a distribution for my project. I'm still not sure I get the hang of it tho. So my setup.py looks like this:

"""
This is a setup.py script generated by py2applet

Usage:
    python setup.py py2app
"""

from setuptools import setup
import setuptools

PACKAGES = ['sqlalchemy.dialects.sqlite']
MODULES = ['sqlite3']

APP = ['tvb/interfaces/web/run.py']
OPTIONS = {'argv_emulation': True,
           'packages': PACKAGES ,
           'includes' : MODULES }
DATA_FILES = []

setup(
    app=APP,
    data_files=DATA_FILES,
    packages = setuptools.find_packages(), 
    include_package_data=True,
    options={'py2app': OPTIONS},
    setup_requires=['py2app', "pyopengl", "cherrypy", "sqlalchemy", "simplejson", 
                          "formencode", "genshi", "quantities","numpy", "scipy",
                          "numexpr", "nibabel", "cfflib", "mdp", "apscheduler",
                          "scikits.learn"]
)

So my first question would be: What should I include in my MODULES for py2app here? Does py2app know to scan for the things in setup_requires and include them or do I need to add some entries for them in MODULES ?

Another problem is that I'm getting an: sqlalchemy.exc.ArgumentError: Could not determine dialect for 'sqlite' when trying to run my app. After lots of googling I only saw that for py2exe you need to include the sqlalchemy.dialects.sqlite as a package but it doesn't seem to work for me. Am I missing something here?

The last one is that I'm getting a: malformed object (load command 3 cmdsize not a multiple of 8) just before the python setup.py py2app. Is this normal?

Regards,
Bogdan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

独﹏钓一江月 2024-12-09 14:40:58

看来我把整件事都搞错了。

'includes' : ['sqlalchemy.dialects.sqlite']

而不是包裹,这似乎已经成功了。

Well seems I got the whole thing wrong.

'includes' : ['sqlalchemy.dialects.sqlite']

Instead of packages, and that seems to have done the trick.

給妳壹絲溫柔 2024-12-09 14:40:58
from setuptools import setup
APP = ['your_prog.py']
DATA_FILES = ['your.db']
OPTIONS = {
'includes' : ['sqlalchemy.dialects.sqlite',"os", "platform"]
}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app']
)

这是包含 sqlite 数据库文件的 .py progs 的示例 setup.py。这是适合初学者的示例 setup.py 文件。
如果 your.db 与 your_prog.py 位于同一目录中,则可以使用此配置。 Macos 应用程序将正常工作。如果不指定 .db 文件,应用程序将运行,但无法连接到数据库文件。

from setuptools import setup
APP = ['your_prog.py']
DATA_FILES = ['your.db']
OPTIONS = {
'includes' : ['sqlalchemy.dialects.sqlite',"os", "platform"]
}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app']
)

This is the sample setup.py for the .py progs that includes sqlite database file. This is the sample setup.py file for beginers.
if your.db in same directory of your_prog.py you can use this configuration. Macos app will work normally as it is. If do not specify the .db file, app will work but couldn't connect to database file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文