Python load_entry_point 简述

来源:互联网 发布:手机淘宝的试用在哪里 编辑:程序博客网 时间:2024/06/05 03:04

fab是个python语言写的部署工具

cat /usr/bin/fab #!/usr/bin/python# EASY-INSTALL-ENTRY-SCRIPT: 'Fabric==1.7.5','console_scripts','fab'__requires__ = 'Fabric==1.7.5'import sysfrom pkg_resources import load_entry_pointif __name__ == '__main__':    sys.exit(        load_entry_point('Fabric==1.7.5', 'console_scripts', 'fab')()    )

其中load_entry_point的用法前提是,fab工具在安装的时候会在*..egg-info文件夹下面的entry_points.txt文件中有相应程序的入口点。

/usr/lib/python2.7/site-packages/Fabric-1.7.5-py2.7.egg-info/entry_points.txt

[console_scripts]fab = fabric.main:main

也就是在fabric module的main.py里面的main函数
/usr/lib/python2.7/site-packages/fabric/main.py

"""This module contains Fab's `main` method plus related subroutines.`main` is executed as the command line ``fab`` program and takes care ofparsing options and commands, loading the user settings file, loading afabfile, and executing the commands given.The other callables defined in this module are internal only. Anything usefulto individuals leveraging Fabric as a library, should be kept elsewhere."""def main(fabfile_locations=None):    """    Main command-line execution loop.    """    try:        # Parse command line options        parser, options, arguments = parse_options()        # Handle regular args vs -- args        arguments = parser.largs        remainder_arguments = parser.rargs        ...
原创粉丝点击