新闻详情

新闻详情

首页 / 资讯中心 / 详情

在 macOS 上如何用 Apple container 容器运行 RustPython 的 Linux 测试?

发布时间:2026/9/14 16:46:16来源:尧图网络
在 macOS 上如何用 Apple container 容器运行 RustPython 的 Linux 测试?
在 macOS 上如何用 Apple container 容器运行 RustPython 的 Linux 测试【免费下载链接】RustPythonA Python Interpreter written in Rust项目地址: https://gitcode.com/GitHub_Trending/ru/RustPythonRustPython 是用 Rust 编写的 Python 解释器开发过程中需要跑它的 Python 标准库测试套件-m test和 Rust 单元测试。在 macOS 上想获得一个 Linux 环境来执行这些测试时不必搭建虚拟机CONTRIBUTING.md 的 “Testing on Linux from macOS” 小节给出了完整流程——用 Apple 的containerCLI 构建一个 Linux 开发镜像启动一个常驻容器然后在容器内执行测试命令。注意文档给出的 setup 命令固定了--arch arm64且注释明确该配置面向 arm64-only builds禁用 Rosetta 要求因此这套命令对应 Apple 芯片的 Mac。前置条件本地已克隆 RustPython 仓库后续所有命令都在仓库根目录下执行该目录包含Cargo.toml和.devcontainer/Dockerfile系统已安装 Homebrew用于安装containerCLI。开发镜像由 .devcontainer/Dockerfile 构建其基础镜像是FROM rust:bullseye并安装clang也就是说容器内的 Rust 工具链来自这个镜像与宿主机上是否装有 Rust 无关。一次性设置安装 CLI 并构建开发镜像在仓库根目录执行对应文档 “Setup (one-time)”# Install container CLI brew install container # Disable Rosetta requirement for arm64-only builds defaults write com.apple.container.defaults build.rosetta -bool false # Build the development image container build --arch arm64 -t rustpython-dev -f .devcontainer/Dockerfile .三条命令的作用依次是通过 Homebrew 安装containerCLI关闭 arm64-only 构建对 Rosetta 的要求以仓库根目录为构建上下文、按.devcontainer/Dockerfile构建一个名为rustpython-dev的 arm64 开发镜像。这三步只需做一次。启动常驻测试容器镜像就绪后启动一个后台常驻容器用于反复执行命令# Start a persistent container in background (8GB memory, 4 CPUs for compilation) container run -d --name rustpython-test -m 8G -c 4 \ --mount typebind,source$(pwd),target/workspace \ -w /workspace rustpython-dev sleep infinity各参数对应文档注释的说明-d后台启动常驻容器--name rustpython-test容器名后续container exec用它定位容器-m 8G -c 4按文档注释分配 8GB 内存、4 个 CPU用于编译--mount typebind,source$(pwd),target/workspace把当前目录即仓库根目录绑定挂载到容器内的/workspace容器里编译出的产物和读取的源码都指向这份本地目录-w /workspace把工作目录设为/workspacerustpython-dev sleep infinity使用上一步构建的镜像并以sleep infinity保持容器不退出以便随时exec进容器执行命令。在容器内运行测试通过container exec在容器内执行测试。文档给出的示例是运行单个标准库测试模块test_ensurepip对应Lib/test下的同名模块# Run tests inside the container container exec rustpython-test sh -c cargo run --release -- -m test test_ensurepip同一条exec模式可用于执行容器内的任意命令文档中演示的是一条 workspace Rust 单元测试# Run any command container exec rustpython-test sh -c cargo test --workspace如果目标是按文档 “Testing” 一节的标准方式跑 Rust 单元测试应使用带排除项的命令rustpython_wasm、rustpython-venvlauncher、rustpython-capi不在其中测试把上面exec的示例换成container exec rustpython-test sh -c cargo test --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher --exclude rustpython-capi而rustpython-capi有独立的cargo配置需要进入crates/capi目录单独测试container exec rustpython-test sh -c cd crates/capi cargo test标准库测试-m test支持文档列出的几个选项在容器里同样适用-j n并行测试文档建议线程数尽量等于 CPU 核数不确定时用-j 4或-j 8本容器按文档配置为 4 个 CPU-v打开详细模式test_name指定只跑单个测试模块。例如全量并行container exec rustpython-test sh -c cargo run --release -- -m test -j 4或者按文档示例只跑test_cmath位于Lib/test/test_cmath并输出详细信息container exec rustpython-test sh -c cargo run --release -- -m test test_cmath -v文档没有给出这些测试命令的示例输出是否通过以测试命令自身打印的结果为准加-v可以看到正在运行的测试的更多信息。收尾停止并删除容器文档的说明是 “Stop and remove the container when done”# Stop and remove the container when done container rm -f rustpython-test该命令会强制停止并删除rustpython-test容器。仓库目录是通过 bind mount 映射进容器的删除容器不会影响本地仓库中的源码。限制说明文档中的 setup 命令固定--arch arm64并关闭 arm64-only 构建的 Rosetta 要求文档未提供面向 Intel Mac 的替代流程容器内工具链来自.devcontainer/Dockerfilerust:bullseyeclang构建的rustpython-dev镜像若该 Dockerfile 有变更需要重新执行container build再启动容器本流程覆盖在 macOS 上用containerCLI 跑 RustPython 的 Linux 测试这一任务若要在 macOS 宿主机上直接开发而非容器内环境要求见 CONTRIBUTING.md 的 “Setting up a development environment” 一节。【免费下载链接】RustPythonA Python Interpreter written in Rust项目地址: https://gitcode.com/GitHub_Trending/ru/RustPython创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
网站建设高端定制企业官网
RELATED

相关资讯

更多精彩内容,欢迎继续阅读

较早相关资讯

最新相关资讯

easy-vibe 计算机基础:数据表示原理全解 —— 从字符编码、存储层次到可靠传输的完整链路 2026/9/14 17:28:21

easy-vibe 计算机基础:数据表示原理全解 —— 从字符编码、存储层次到可靠传输的完整链路

easy-vibe 计算机基础:数据表示原理全解 —— 从字符编码、存储层次到可靠传输的完整链路 【免费下载链接】easy-vibe 💻 vibe coding 101|The first course for AI-native product builders. 项目地址: https://gitcode.com/GitHub_Trendi…

阅读更多 →
Garnet 分布式缓存:微软为什么用 .NET 从零重写整个缓存存储栈 2026/9/14 17:28:21

Garnet 分布式缓存:微软为什么用 .NET 从零重写整个缓存存储栈

Garnet 分布式缓存:微软为什么用 .NET 从零重写整个缓存存储栈 【免费下载链接】garnet Garnet is a remote cache-store from Microsoft Research that offers strong performance (throughput and latency), scalability, storage, recovery, cluster sharding, k…

阅读更多 →
Linux BPF 文件系统 kfuncs 详解:BPF LSM 程序如何安全地访问文件数据 2026/9/14 17:28:21

Linux BPF 文件系统 kfuncs 详解:BPF LSM 程序如何安全地访问文件数据

Linux BPF 文件系统 kfuncs 详解:BPF LSM 程序如何安全地访问文件数据 【免费下载链接】linux Linux kernel source tree 项目地址: https://gitcode.com/GitHub_Trending/li/linux BPF LSM 程序在 LSM 钩子中被执行时,常常需要读取文件相关的内核…

阅读更多 →
Windmill Python Client 文档构建指南:基于 pdoc 的 API 文档生成、发布与部署全解析 2026/9/14 17:28:21

Windmill Python Client 文档构建指南:基于 pdoc 的 API 文档生成、发布与部署全解析

Windmill Python Client 文档构建指南:基于 pdoc 的 API 文档生成、发布与部署全解析 【免费下载链接】windmill Open-source developer platform to power your entire infra and turn scripts into webhooks, workflows and UIs. Fastest workflow engine (13x vs…

阅读更多 →
a2ui Express 编译器字符串到数字自动强转(Auto-Coercion)实验复盘:一次被回滚的格式优化迭代 2026/9/14 17:28:21

a2ui Express 编译器字符串到数字自动强转(Auto-Coercion)实验复盘:一次被回滚的格式优化迭代

a2ui Express 编译器字符串到数字自动强转(Auto-Coercion)实验复盘:一次被回滚的格式优化迭代 【免费下载链接】a2ui 项目地址: https://gitcode.com/GitHub_Trending/a2/a2ui 本篇文章基于 a2ui 仓库中迭代式格式优化(It…

阅读更多 →
Bazel 如何用 persistent worker 策略降低编译启动开销? 2026/9/14 17:25:21

Bazel 如何用 persistent worker 策略降低编译启动开销?

Bazel 如何用 persistent worker 策略降低编译启动开销? 【免费下载链接】bazel a fast, scalable, multi-language and extensible build system 项目地址: https://gitcode.com/GitHub_Trending/ba/bazel 当一次构建包含大量编译 action 时,Baz…

阅读更多 →

今日资讯

本周资讯

本月资讯

看完文章仍有疑问?

联系尧图顾问,获取一对一建站咨询

立即免费咨询 📞 400-888-8888
📞