Ai
1 Star 0 Fork 0

lpwm/python-build-standalone

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test-distribution.py 1.28 KB
一键复制 编辑 原始数据 按行查看 历史
#!/usr/bin/env python3
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
"""Script to run Python tests from a distribution archive."""
import json
import pathlib
import subprocess
import sys
import tarfile
import tempfile
import zstandard
def main(args):
if not args:
print("Usage: test-distribution.py path/to/distribution.tar.zst")
return 1
distribution_path = args[0]
with tempfile.TemporaryDirectory() as td:
td = pathlib.Path(td)
with open(distribution_path, "rb") as fh:
dctx = zstandard.ZstdDecompressor()
with dctx.stream_reader(fh) as reader:
with tarfile.open(mode="r|", fileobj=reader) as tf:
tf.extractall(td)
root = td / "python"
python_json = root / "PYTHON.json"
with python_json.open("rb") as fh:
info = json.load(fh)
test_args = [
str(root / info["python_exe"]),
str(root / info["run_tests"]),
]
test_args.extend(args[1:])
return subprocess.run(test_args).returncode
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lpwm/python-build-standalone.git
git@gitee.com:lpwm/python-build-standalone.git
lpwm
python-build-standalone
python-build-standalone
main

搜索帮助