修复环境变量路径
This commit is contained in:
@@ -33,25 +33,27 @@ if __name__ == "__main__":
|
||||
|
||||
wda.debug = True
|
||||
|
||||
# 1. 拿到打包后的临时目录
|
||||
base_dir = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
|
||||
# 1. 打包环境
|
||||
if hasattr(sys, '_MEIPASS'):
|
||||
base_dir = sys._MEIPASS
|
||||
# 2. 源码调试环境
|
||||
else:
|
||||
base_dir = os.path.dirname(
|
||||
os.path.dirname(os.path.abspath(__file__)) # 向上跳一级
|
||||
)
|
||||
|
||||
# 2. 构造 resources/iproxy 绝对路径
|
||||
# 3. 拼 iproxy 目录
|
||||
iproxy_dir = os.path.join(base_dir, 'resources', 'iproxy')
|
||||
|
||||
# 3. 如果目录存在就追加到 PATH
|
||||
# 4. 剩余逻辑不变
|
||||
if os.path.isdir(iproxy_dir):
|
||||
# Windows 用 ; 分隔,Linux/Mac 用 :
|
||||
sep = os.pathsep
|
||||
old_path = os.environ.get('PATH', '')
|
||||
# 避免重复追加
|
||||
if iproxy_dir not in old_path:
|
||||
os.environ['PATH'] = old_path + sep + iproxy_dir
|
||||
else:
|
||||
# 调试用,打包后可删掉
|
||||
print(f'warning: {iproxy_dir} not found', file=sys.stderr)
|
||||
|
||||
|
||||
# 添加iOS开发包到电脑上
|
||||
deployer = DevDiskImageDeployer(verbose=True)
|
||||
deployer.deploy_all()
|
||||
|
||||
Reference in New Issue
Block a user