lg_cffi_setup.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:lemongraph 作者: NationalSecurityAgency 项目源码 文件源码
def keywords_with_side_effects(argv, **kwargs):
    def is_short_option(argument):
        """Check whether a command line argument is a short option."""
        return len(argument) >= 2 and argument[0] == '-' and argument[1] != '-'

    def expand_short_options(argument):
        """Expand combined short options into canonical short options."""
        return ('-' + char for char in argument[1:])

    def argument_without_setup_requirements(argv, i):
        """Check whether a command line argument needs setup requirements."""
        if argv[i] in NO_SETUP_REQUIRES_ARGUMENTS:
            # Simple case: An argument which is either an option or a command
            # which doesn't need setup requirements.
            return True
        elif (is_short_option(argv[i]) and
              all(option in NO_SETUP_REQUIRES_ARGUMENTS
                  for option in expand_short_options(argv[i]))):
            # Not so simple case: Combined short options none of which need
            # setup requirements.
            return True
        elif argv[i - 1:i] == ['--egg-base']:
            # Tricky case: --egg-info takes an argument which should not make
            # us use setup_requires (defeating the purpose of this code).
            return True
        else:
            return False

    if all(argument_without_setup_requirements(argv, i)
           for i in range(1, len(argv))):
        try:
            cmdclass = kwargs["cmdclass"]
        except KeyError:
            cmdclass = kwargs["cmdclass"] = {}
        cmdclass["build"] = DummyCFFIBuild
        cmdclass["install"] = DummyCFFIInstall

    return kwargs
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号