easy_install.py 文件源码

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

项目:Flask_Blog 作者: sugarguo 项目源码 文件源码
def install_script(self, dist, script_name, script_text, dev_path=None):
        """Generate a legacy script wrapper and install it"""
        spec = str(dist.as_requirement())
        is_script = is_python_script(script_text, script_name)

        def get_template(filename):
            """
            There are a couple of template scripts in the package. This
            function loads one of them and prepares it for use.

            These templates use triple-quotes to escape variable
            substitutions so the scripts get the 2to3 treatment when build
            on Python 3. The templates cannot use triple-quotes naturally.
            """
            raw_bytes = resource_string('setuptools', template_name)
            template_str = raw_bytes.decode('utf-8')
            clean_template = template_str.replace('"""', '')
            return clean_template

        if is_script:
            template_name = 'script template.py'
            if dev_path:
                template_name = template_name.replace('.py', ' (dev).py')
            script_text = (get_script_header(script_text) +
                get_template(template_name) % locals())
        self.write_script(script_name, _to_ascii(script_text), 'b')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号