加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
setup.py 1.27 KB
一键复制 编辑 原始数据 按行查看 历史
EveryTian 提交于 2019-02-01 14:29 . End
from setuptools import setup, find_packages
import platform
is_windows = platform.platform()[:3].lower() == 'win'
setup(
name='books',
version='1.0',
description='CLI Reading Progress Management',
url='https://github.com/EveryTian/BooksStatus',
packages=find_packages(),
author='EveryTian',
author_email='haotian_ren@outlook.com',
scripts=['books/books.bat' if is_windows else 'books/books'],
zip_safe=False
)
try:
from books import base
project_folder_path = base.get_project_folder_path()
from subprocess import Popen, PIPE
get_script_path_cmd = 'where books' if is_windows else 'which books'
script_path = Popen(get_script_path_cmd, stdout=PIPE, shell=True).communicate()[0].strip()
script_file_lines = []
with open(script_path, 'r') as f:
modified_flag = False
for l in f:
if not modified_flag and l.rstrip().endswith('#####'):
the_line = script_file_lines[-1]
script_file_lines[-1] = the_line[:the_line.index('=') + 1] + project_folder_path + '\n'
modified_flag = True
script_file_lines.append(l)
with open(script_path, 'w') as f:
f.writelines(script_file_lines)
except Exception as e:
import sys
sys.stderr.write(str(e))
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化