new-modular-project
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWhen the user wants to create a new project, first infer as many options as
possible from the user's request (e.g., "new Mojo project" means type=Mojo,
"called foo" means name=foo). Then use a structured multiple-choice prompt (not
plain text) to gather only the remaining unspecified options in a single
interaction. Do NOT ask about options the user has already provided or implied.
The options to determine are:
- Project name — ask if not specified
- Type of project — Mojo or MAX (infer from context if the user said "Mojo project" or "MAX project")
- Environment manager — Pixi (recommended) or uv
- If uv: UV project type — full uv project (+
uv init, recommended) or quick uv environment (uv add+uv venv, lighter weight)uv pip install - Channel — nightly (latest features, recommended) or stable (production)
Then follow the appropriate section below (Pixi or uv) to initialize the
project and choose or as appropriate. For stable versions in the
below examples, will start with a 0. prefix (0.26.1.0.0.0) where
packages will not (26.1.0.0.0).
maxmojomojomaxNOTE: Do not look for or use for Mojo or MAX projects, it is no longer
supported. Pixi has fully replaced its capabilities.
magic当用户想要创建新项目时,首先从用户的请求中推断出尽可能多的选项(例如,“new Mojo project”表示项目类型为Mojo,“名为foo”表示项目名称为foo)。然后使用结构化的选择题提示(而非纯文本),在一次交互中仅收集剩余未指定的选项。不要询问用户已经提供或隐含的选项。需要确定的选项包括:
- 项目名称——若未指定则询问
- 项目类型——Mojo或MAX(如果用户提到“Mojo project”或“MAX project”,可从上下文推断)
- 环境管理器——Pixi(推荐)或uv
- 若选择uv:UV项目类型——完整uv项目(+
uv init,推荐)或快速uv环境(uv add+uv venv,更轻量化)uv pip install - 渠道——nightly(最新功能,推荐)或stable(生产环境)
随后根据选择的环境(Pixi或uv),按照下方对应的章节初始化项目,并选择合适的或。在以下示例的稳定版本中,版本号将以0.开头(如0.26.1.0.0.0),而包的版本号则不会(如26.1.0.0.0)。
maxmojomojomax注意:请勿为Mojo或MAX项目寻找或使用,该工具已不再受支持。Pixi已完全替代了它的功能。
magicPixi (Recommended)
Pixi(推荐)
Pixi manages Python, Mojo, and other dependencies in a reproducible
manner inside a controlled environment.
First, determine if is installed. If it is not available for use at the
command line, install it using the latest instructions found on
https://pixi.prefix.dev/latest/#installation
pixiYou may need to place the tool in the local shell environment after
installation if it had not already been installed.
pixiPixi在受控环境中以可复现的方式管理Python、Mojo及其他依赖项。
安装完成后,若未自动加入本地Shell环境,你可能需要手动配置。
pixiNightly
Nightly版本
bash
undefinedbash
undefinedNew project
新项目
pixi init [PROJECT]
-c https://conda.modular.com/max-nightly/ -c conda-forge
&& cd [PROJECT] pixi add [max / mojo] pixi shell
-c https://conda.modular.com/max-nightly/ -c conda-forge
&& cd [PROJECT] pixi add [max / mojo] pixi shell
pixi init [PROJECT]
-c https://conda.modular.com/max-nightly/ -c conda-forge
&& cd [PROJECT] pixi add [max / mojo] pixi shell
-c https://conda.modular.com/max-nightly/ -c conda-forge
&& cd [PROJECT] pixi add [max / mojo] pixi shell
Existing project - add to pixi.toml channels first:
现有项目 - 先在pixi.toml中添加渠道:
[workspace]
[workspace]
channels = ["https://conda.modular.com/max-nightly/", "conda-forge"]
channels = ["https://conda.modular.com/max-nightly/", "conda-forge"]
pixi add [max / mojo]
undefinedpixi add [max / mojo]
undefinedStable (v26.1.0.0.0)
稳定版本(v26.1.0.0.0)
bash
undefinedbash
undefinedNew project
新项目
pixi init [PROJECT]
-c https://conda.modular.com/max/ -c conda-forge
&& cd [PROJECT] pixi add "[max / mojo]==0.26.1.0.0.0" pixi shell
-c https://conda.modular.com/max/ -c conda-forge
&& cd [PROJECT] pixi add "[max / mojo]==0.26.1.0.0.0" pixi shell
pixi init [PROJECT]
-c https://conda.modular.com/max/ -c conda-forge
&& cd [PROJECT] pixi add "[max / mojo]==0.26.1.0.0.0" pixi shell
-c https://conda.modular.com/max/ -c conda-forge
&& cd [PROJECT] pixi add "[max / mojo]==0.26.1.0.0.0" pixi shell
Existing project
现有项目
pixi add "[max / mojo]==0.26.1.0.0.0"
---pixi add "[max / mojo]==0.26.1.0.0.0"
---uv
uv
uv is a fast and very popular package manager, familiar to developers coming
from a Python background. It also works well with Mojo projects.
uv是一款快速且广受欢迎的包管理器,熟悉Python的开发者会对其感到亲切。它也能很好地适配Mojo项目。
Nightly (project)
Nightly版本(完整项目)
bash
uv init [PROJECT] && cd [PROJECT]
uv add [max / mojo] \
--index https://whl.modular.com/nightly/simple/ \
--prerelease allowbash
uv init [PROJECT] && cd [PROJECT]
uv add [max / mojo] \
--index https://whl.modular.com/nightly/simple/ \
--prerelease allowStable (project)
稳定版本(完整项目)
bash
uv init [PROJECT] && cd [PROJECT]
uv add [max / mojo] \
--extra-index-url https://modular.gateway.scarf.sh/simple/bash
uv init [PROJECT] && cd [PROJECT]
uv add [max / mojo] \
--extra-index-url https://modular.gateway.scarf.sh/simple/Nightly (quick environment)
Nightly版本(快速环境)
bash
mkdir [PROJECT] && cd [PROJECT]
uv venv
uv pip install [max / mojo] \
--index https://whl.modular.com/nightly/simple/ \
--prerelease allowbash
mkdir [PROJECT] && cd [PROJECT]
uv venv
uv pip install [max / mojo] \
--index https://whl.modular.com/nightly/simple/ \
--prerelease allowStable (quick environment)
稳定版本(快速环境)
bash
mkdir [PROJECT] && cd [PROJECT]
uv venv
uv pip install [max / mojo] \
--extra-index-url https://modular.gateway.scarf.sh/simple/When using , you can use or directly by working within the project environment:
uvmaxmojobash
source .venv/bin/activatebash
mkdir [PROJECT] && cd [PROJECT]
uv venv
uv pip install [max / mojo] \
--extra-index-url https://modular.gateway.scarf.sh/simple/使用时,你可以通过进入项目环境直接使用或:
uvmaxmojobash
source .venv/bin/activatepip
pip
Standard Python package manager.
标准Python包管理器。
Nightly
Nightly版本
bash
python3 -m venv .venv && source .venv/bin/activate
pip install --pre [max / mojo] \
--index https://whl.modular.com/nightly/simple/bash
python3 -m venv .venv && source .venv/bin/activate
pip install --pre [max / mojo] \
--index https://whl.modular.com/nightly/simple/Stable
稳定版本
bash
python3 -m venv .venv && source .venv/bin/activate
pip install [max / mojo] \
--extra-index-url https://modular.gateway.scarf.sh/simple/bash
python3 -m venv .venv && source .venv/bin/activate
pip install [max / mojo] \
--extra-index-url https://modular.gateway.scarf.sh/simple/Conda
Conda
For conda/mamba users.
适用于conda/mamba用户。
Nightly
Nightly版本
bash
conda install -c conda-forge \
-c https://conda.modular.com/max-nightly/ [max / mojo]bash
conda install -c conda-forge \
-c https://conda.modular.com/max-nightly/ [max / mojo]Stable (v26.1.0.0.0)
稳定版本(v26.1.0.0.0)
bash
conda install -c conda-forge \
-c https://conda.modular.com/max/ "[max / mojo]==0.26.1.0.0.0"bash
conda install -c conda-forge \
-c https://conda.modular.com/max/ "[max / mojo]==0.26.1.0.0.0"Version Alignment with MAX
与MAX版本对齐
If using MAX with custom Mojo kernels, versions must match:
bash
undefined若将MAX与自定义Mojo内核配合使用,版本必须保持一致:
bash
undefinedCheck alignment
检查版本一致性
uv pip show mojo | grep Version # e.g., 0.26.2
pixi run mojo --version # Must match major.minor (e.g., 0.26.2)
Mismatched versions cause kernel compilation failures. Always use the same channel (stable or nightly) for both.
---uv pip show mojo | grep Version # 示例:0.26.2
pixi run mojo --version # 必须与主版本.次版本匹配(示例:0.26.2)
版本不匹配会导致内核编译失败。请始终为两者使用相同的渠道(stable或nightly)。
---