所以對於一個Python包,你怎麼能夠從一個點安裝的軟件包命令行參數?下面是一個名爲mrbob的包的示例:如何才能啓用安裝PIP Python包shell命令行參數?
$ pip install mrbob
$ mrbob DoSomethingFunction
如何爲python包啓用命令行選項和新shell命令?
所以對於一個Python包,你怎麼能夠從一個點安裝的軟件包命令行參數?下面是一個名爲mrbob的包的示例:如何才能啓用安裝PIP Python包shell命令行參數?
$ pip install mrbob
$ mrbob DoSomethingFunction
如何爲python包啓用命令行選項和新shell命令?
隨着setuptools
,定義console_script
切入點:
setup(
# other arguments here...
entry_points={
'console_scripts': [
'mrbob = my_package.some_module:main_func',
]
}
)
有關詳細信息,請參閱setuptools
文檔automatic script creation。
隨着distutils
,使用scripts
:
setup(...,
scripts=['scripts/mrbob']
)
有關詳細信息,請參閱distutils
文檔installing scripts。
mrbob
將被安裝在bin
目錄 例如在我的情況下,它是:
/Library/Frameworks/Python.framework/Versions/2.7/bin/
只要這是你的$PATH
你是好人。
是「你」,「你」和「是」真的這麼難打出來? – dimo414
如果包不支持此功能,你必須寫自己的CLI包裝。 –
'mrbob'將不得不加入到系統PATH –