8 Star 59 Fork 21

Gitee 极速下载/Calibre

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/kovidgoyal/calibre
克隆/下载
update-on-ox 1.85 KB
一键复制 编辑 原始数据 按行查看 历史
Kovid Goyal 提交于 2022-07-04 08:45 . There is no python anymore on macOS
#!/usr/bin/env python3
# vim:fileencoding=utf-8
# License: GPL v3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
import ast
import atexit
import glob
import os
import re
import shlex
import shutil
import subprocess
import sys
import tempfile
if False:
dmg = sys.argv[-1]
mp = tempfile.mkdtemp()
atexit.register(os.rmdir, mp)
subprocess.check_call('hdiutil attach {} -mountpoint {}'.format(dmg, mp).split())
try:
os.chdir(mp)
for app in glob.glob('*.app'):
d = os.path.join('/Applications', app)
if os.path.exists(d):
shutil.rmtree(d)
subprocess.check_call('ditto -v {} {}'.format(app, os.path.join('/Applications', app)).split())
finally:
os.chdir('/')
subprocess.check_call('hdiutil detach {}'.format(mp).split())
# EOF_REMOTE
HOST = 'ox'
base = os.path.dirname(os.path.abspath(__file__))
if True:
with open(os.path.join(base, 'src/calibre/constants.py')) as f:
raw = f.read()
v = re.search(r'numeric_version\s*=\s*(\(.+?\))', raw).group(1)
v = '.'.join(map(str, ast.literal_eval(v)))
dmg = f'calibre-{v}.dmg'
def run(what):
ret = subprocess.run(shlex.split(what))
if ret.returncode != 0:
raise SystemExit(ret.returncode)
with open(__file__, 'rb') as f:
script = f.read().decode('utf-8')
script = script[:script.find('# EOF_REMOTE')].replace('if False:', 'if True:', 1)
with tempfile.NamedTemporaryFile(prefix='install-dmg-', suffix='.py') as f:
cmd = './setup.py osx --dont-shutdown'
if 'develop' in sys.argv:
print('Disabling code-signing and notarization')
cmd += ' --dont-sign --dont-notarize --dont-strip'
run(cmd)
f.write(script.encode('utf-8'))
f.flush()
run(f'scp dist/{dmg} {f.name} {HOST}:/tmp')
run(f'ssh {HOST} python3 /tmp/{os.path.basename(f.name)} /tmp/{dmg}')
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/mirrors/Calibre.git
git@gitee.com:mirrors/Calibre.git
mirrors
Calibre
Calibre
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385