那么对于 python 包,如何从 pip 安装的包启用命令行参数?下面是一个名为 mrbob 的包的示例:
$ pip install mrbob
$ mrbob DoSomethingFunction
Run Code Online (Sandbox Code Playgroud)
如何为 python 包启用命令行选项和新的 shell 命令?
使用setuptools,定义一个console_script入口点:
setup(
# other arguments here...
entry_points={
'console_scripts': [
'mrbob = my_package.some_module:main_func',
]
}
)
Run Code Online (Sandbox Code Playgroud)
有关更多详细信息,请参阅文档中的自动脚本创建。setuptools
与distutils, 使用scripts:
setup(...,
scripts=['scripts/mrbob']
)
Run Code Online (Sandbox Code Playgroud)
有关更多详细信息,请参阅文档中的安装脚本。distutils
| 归档时间: |
|
| 查看次数: |
308 次 |
| 最近记录: |