我尝试生成一个可执行的*.egg
文件。我可以使用以下方法创建它:我只需将__main__.py
放在名为.zip
的.egg
的顶层,python将运行该__main__.py
我读到有一种更优雅的方式:
setup(
# other arguments here...
entry_points={
'setuptools.installation': [
'eggsecutable = my_package.some_module:main_func',
]
}
)
https://setuptools.readthedocs.io/en/latest/setuptools.html#eggsecutable-scripts
但是如果我创建(使用run setup.py bdist_egg
)并运行*.egg
,它将打印:
C:\Python27\python.exe: can't find '__main__' module in <eggpath>
所以python找不到入口点。在
没有显式的__main__.py
就可以生成一个可执行的egg吗?
系统:
更新
我在Linux上都用python3尝试过这两种方法,但我得到了相同的错误。在
入口点文档似乎有误导性,您不需要它们。在
你可能想要这样的东西:
setup.py
:
^{pr2}$example_pkg/stuff.py
制作鸡蛋:
setup.py bdist_egg
运行卵子:
python dist\example_pkg-0.0.1-py3.6.egg
输出:
egg test
解决方案来源:https://mail.python.org/pipermail/distutils-sig/2015-June/026524.html
相关问题 更多 >
编程相关推荐