> This page is for version 0.5.1.
> For other versions, use one of these documentation indexes:
> - Main (default): https://docs.nvidia.com/nemo/gym/main/llms.txt
> - 0.7.0: https://docs.nvidia.com/nemo/gym/v0.7.0/llms.txt
> - 0.6.0: https://docs.nvidia.com/nemo/gym/v0.6.0/llms.txt
> - 0.5.1: https://docs.nvidia.com/nemo/gym/v0.5.1/llms.txt
> - 0.5.0: https://docs.nvidia.com/nemo/gym/v0.5.0/llms.txt
> - 0.4.0: https://docs.nvidia.com/nemo/gym/v0.4.0/llms.txt
> - 0.3.0: https://docs.nvidia.com/nemo/gym/v0.3.0/llms.txt
> - 0.2.1: https://docs.nvidia.com/nemo/gym/v0.2.1/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/gym/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/gym/_mcp/server.

# nemo_gym.cli.setup_command

## Module Contents

### Functions

| Name                                                                                     | Description                                                                                                          |
| ---------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| [`_get_nemo_gym_install_flags`](#nemo_gym-cli-setup_command-_get_nemo_gym_install_flags) | Build uv pip install flags for nemo-gym in sub-venvs.                                                                |
| [`_get_nemo_gym_version_spec`](#nemo_gym-cli-setup_command-_get_nemo_gym_version_spec)   | Detect nemo-gym version from parent venv and return version specifier.                                               |
| [`_local_nemo_gym_extras`](#nemo_gym-cli-setup_command-_local_nemo_gym_extras)           | The extras a server requests on its local Gym requirement, formatted as `[a,b]`, or "" for none.                     |
| [`get_venv_path`](#nemo_gym-cli-setup_command-get_venv_path)                             | Resolve the venv a server runs from: `uv_venv_dir/&lt;type&gt;/&lt;name&gt;/.venv`, else `&lt;server dir&gt;/.venv`. |
| [`run_command`](#nemo_gym-cli-setup_command-run_command)                                 | -                                                                                                                    |
| [`setup_env_command`](#nemo_gym-cli-setup_command-setup_env_command)                     | -                                                                                                                    |

### Data

[`_LOCAL_NEMO_GYM_REQUIREMENT_RE`](#nemo_gym-cli-setup_command-_LOCAL_NEMO_GYM_REQUIREMENT_RE)

### API

```python
nemo_gym.cli.setup_command._get_nemo_gym_install_flags() -> str
```

Build uv pip install flags for nemo-gym in sub-venvs.

Supports:

* Pre-release versions via NEMO\_GYM\_ALLOW\_PRERELEASE=true
* Custom PyPI indexes via UV\_INDEX\_URL, UV\_EXTRA\_INDEX\_URL, UV\_INDEX\_STRATEGY
* Auto-detection of parent venv version for consistency

**Returns:** `str`

String of flags to add to 'uv pip install nemo-gym'

```python
nemo_gym.cli.setup_command._get_nemo_gym_version_spec(
    is_editable_install: bool
) -> str
```

Detect nemo-gym version from parent venv and return version specifier.

**Parameters:**

**`is_editable_install`** `bool`

Whether nemo-gym is installed in editable mode in parent venv

---

**Returns:** `str`

Version specifier string (e.g., "==0.2.1rc0") or empty string

```python
nemo_gym.cli.setup_command._local_nemo_gym_extras(
    requirements_fpath: pathlib.Path
) -> str
```

The extras a server requests on its local Gym requirement, formatted as `[a,b]`, or "" for none.

Installs from PyPI replace the server's `nemo-gym[...] @ ../../` line with a `nemo-gym` requirement, so
its extras must be carried over or their dependencies are never installed.

```python
nemo_gym.cli.setup_command.get_venv_path(
    dir_path: pathlib.Path,
    global_config_dict: omegaconf.DictConfig
) -> pathlib.Path
```

Resolve the venv a server runs from: `uv_venv_dir/&lt;type&gt;/&lt;name&gt;/.venv`, else `&lt;server dir&gt;/.venv`.

Callers need this to launch a server with the venv's own interpreter rather than trusting whatever
`bin/activate` puts on PATH. A venv copied or moved after creation keeps the *original* prefix
hard-coded in `bin/activate`, so sourcing it silently hands the server a different interpreter than
the one `uv_venv_dir` asked for.

```python
nemo_gym.cli.setup_command.run_command(
    command: str,
    working_dir_path: pathlib.Path,
    server_name: str = '',
    project_root: pathlib.Path | None = None,
    global_config_dict: omegaconf.DictConfig | None = None,
    stdout_target: typing.IO[typing.Any] | None = None,
    stderr_target: typing.IO[typing.Any] | None = None,
    extra_env: typing.Mapping[str, str] | None = None
) -> subprocess.Popen
```

```python
nemo_gym.cli.setup_command.setup_env_command(
    dir_path: pathlib.Path,
    global_config_dict: omegaconf.DictConfig,
    prefix: str
) -> str
```

```python
nemo_gym.cli.setup_command._LOCAL_NEMO_GYM_REQUIREMENT_RE = re.compile('^\\s*(?:-e\\s+)?nemo[-_]gym\\s*(?:\\[(?P<extras>[^\\]]*)\\])?\\s*@\\...
```