def fix_shebang(file_path, python_version):
"""Rewrite the shebang for the used major python version of the install,
use simply sed from OS"""
print("fix python version")
# accept array of python version from platform.python_version_tuple()
# fix shebang only with major python version
sed = "sed -i 's/#!.*\/usr\/bin\/.*python.*$/#!\/usr\/bin\/env python{}/'"\
.format(python_version[0], python_version[1])
# bring command together with file path
cmd = ' '.join([sed, file_path])
# execute the sed command and replace in place
os.system(cmd)
# Get current Python version
评论列表
文章目录