install_whl.py 文件源码

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

项目:bpy_lambda 作者: bcongdon 项目源码 文件源码
def update_init_file(version: tuple):
    import os
    import re

    print('Updating __init__.py to have the correct version.')
    version_line_re = re.compile(r'^\s+[\'"]version[\'"]: (\([0-9,]+\)),')

    with open('__init__.py', 'r') as infile, \
         open('__init__.py~whl~installer~', 'w') as outfile:

        for line in infile:
            if version_line_re.match(line):
                outfile.write("    'version': %s,%s" % (version, os.linesep))
            else:
                outfile.write(line)

    os.unlink('__init__.py')
    os.rename('__init__.py~whl~installer~', '__init__.py')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号