首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >分发、epydoc和setup.py

分发、epydoc和setup.py
EN

Stack Overflow用户
提问于 2012-11-23 21:02:12
回答 1查看 409关注 0票数 1

我希望有一个为我的包运行epydoc的目标(比如docs)。我假设我需要创建一个新的命令,但我没有太多的运气。

以前有人这么做过吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-23 21:27:24

Babel project提供了几个在setup.py文件中使用的命令。

您需要使用命令定义distutils.commands入口点;Babel setup.py file中的示例

代码语言:javascript
复制
entry_points = """
[distutils.commands]
compile_catalog = babel.messages.frontend:compile_catalog
extract_messages = babel.messages.frontend:extract_messages
init_catalog = babel.messages.frontend:init_catalog
update_catalog = babel.messages.frontend:update_catalog
"""

在这里,额外的命令可以作为python setup.py commandname使用。

入口点指向from distutils.cmd import Command的子类。同样来自巴别塔的例子,来自babel.messages.frontend module

代码语言:javascript
复制
from distutils.cmd import Command
from distutils.errors import DistutilsOptionError


class compile_catalog(Command):
    """Catalog compilation command for use in ``setup.py`` scripts."""

    # Description shown in setup.py --help-commands
    description = 'compile message catalogs to binary MO files'
    # Options available for this command, tuples of ('longoption', 'shortoption', 'help')
    # If the longoption name ends in a `=` it takes an argument
    user_options = [
        ('domain=', 'D',
         "domain of PO file (default 'messages')"),
        ('directory=', 'd',
         'path to base directory containing the catalogs'),
        # etc.
    ]
    # Options that don't take arguments, simple true or false options.
    # These *must* be included in user_options too, but without a = equals sign
    boolean_options = ['use-fuzzy', 'statistics']

    def initialize_options(self):
        # Set a default for each of your user_options (long option name)

    def finalize_options(self):
        # verify the arguments and raise DistutilOptionError if needed

    def run(self):
        # Do your thing here.
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13529722

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档