Skip to content

Commit b6635e4

Browse files
authored
Update uv add installation docs (#351)
This PR improves installation documentation with clearer instructions for uv add workflow. Changes: - Add detailed instructions for uv add installation method. - Add troubleshooting tips for Windows MarkupSafe installation issues with `uv add` installation workflow. - Add note about `uv sync --upgrade` to update dependencies for local development builds. - Update pytorch cuda wheel links
1 parent a76f6ec commit b6635e4

File tree

4 files changed

+71
-59
lines changed

4 files changed

+71
-59
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ Thank you for your interest in contributing to sleap-nn! This guide will help yo
4141
```bash
4242
uv sync --extra dev --extra torch-cpu
4343
```
44-
44+
> **Upgrading All Dependencies**
45+
> To ensure you have the latest versions of all dependencies, use the `--upgrade` flag with `uv sync`:
46+
> ```bash
47+
> uv sync --extra dev --upgrade
48+
> ```
49+
> This will upgrade all installed packages in your environment to the latest available versions compatible with your `pyproject.toml`.
4550
4651
## Code Style
4752

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,10 @@ powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
8181
uv run black --check sleap_nn tests
8282
uv run ruff check sleap_nn/
8383
```
84+
85+
> **Upgrading All Dependencies**
86+
> To ensure you have the latest versions of all dependencies, use the `--upgrade` flag with `uv sync`:
87+
> ```bash
88+
> uv sync --extra dev --upgrade
89+
> ```
90+
> This will upgrade all installed packages in your environment to the latest available versions compatible with your `pyproject.toml`.

docs/index.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@
2323

2424
Let's start SLEAPiNNg !!! 🐭🐭
2525

26-
!!! info "Prerequisite: uv installation"
27-
Install [`uv`](https://github.com/astral-sh/uv), a fast Python package manager for modern projects:
28-
```bash
29-
# macOS/Linux
30-
curl -LsSf https://astral.sh/uv/install.sh | sh
31-
32-
# Windows
33-
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
34-
```
26+
**Prerequisite: uv installation**
27+
28+
Install [`uv`](https://github.com/astral-sh/uv), a fast Python package manager for modern projects:
29+
```bash
30+
# macOS/Linux
31+
curl -LsSf https://astral.sh/uv/install.sh | sh
32+
33+
# Windows
34+
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
35+
```
3536

3637
### Step - 1 : Set Up Your Configuration
3738

@@ -68,7 +69,7 @@ We use `uvx` here which automatically installs sleap-nn from PyPI with all depen
6869

6970
!!! info
7071
- For more information on which CUDA version to use for your system, see the [PyTorch installation guide](https://pytorch.org/get-started/locally/).
71-
The `--index` in the install command should match the CUDA version you need (e.g., `https://download.pytorch.org/whl/cuda118` for CUDA 11.8, `https://download.pytorch.org/whl/cuda128` for CUDA 12.8, etc.).
72+
The `--index` in the install command should match the CUDA version you need (e.g., `https://download.pytorch.org/whl/cu118` for CUDA 11.8, `https://download.pytorch.org/whl/cu128` for CUDA 12.8, etc.).
7273
- On macOS, MPS (Metal Performance Shaders) is automatically enabled for Apple Silicon acceleration.
7374

7475

@@ -93,7 +94,7 @@ To run inference:
9394

9495
!!! info
9596
- For more information on which CUDA version to use for your system, see the [PyTorch installation guide](https://pytorch.org/get-started/locally/).
96-
The `--index` in the install command should match the CUDA version you need (e.g., `https://download.pytorch.org/whl/cuda118` for CUDA 11.8, `https://download.pytorch.org/whl/cuda128` for CUDA 12.8, etc.).
97+
The `--index` in the install command should match the CUDA version you need (e.g., `https://download.pytorch.org/whl/cu118` for CUDA 11.8, `https://download.pytorch.org/whl/cu128` for CUDA 12.8, etc.).
9798
- On macOS, MPS (Metal Performance Shaders) is automatically enabled for Apple Silicon acceleration.
9899

99100

docs/installation.md

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
# Installation
22

3-
**Prerequisites:** Python 3.11+ (required for all installation methods)
3+
**Prerequisites:**
4+
5+
Python 3.11 (or) 3.12 (or) 3.13 (required for all installation methods)
46

57
!!! warning "Python 3.14 is not yet supported"
68
`sleap-nn` currently supports **Python 3.11, 3.12, and 3.13**. **Python 3.14 is not yet tested or supported.** If you have Python 3.14 installed, you must specify the Python version in all `uv` install commands by adding `--python 3.13`.
79
For example:
810
```bash
11+
# for uv tool install
912
uv tool install --python 3.13 "sleap-nn[torch]" ...
13+
14+
# for uvx
15+
uvx --python 3.13 ...
16+
17+
# for uv add setup; specify version in uv init
18+
uv init --python 3.13
19+
20+
# for uv sync
21+
uv sync --python 3.13 ...
1022
```
1123
Replace `...` with the rest of your install command as needed.
1224

25+
1326
!!! tip "Choose Your Installation Method"
1427
- **[Installation as a system-wide tool with uv](#installation-as-a-system-wide-tool-with-uv)**: **(Recommended)** Use `uv tool install` to install sleap-nn globally as a CLI tool
1528
- **[Installation with uvx](#installation-with-uvx)**: Use `uvx` for one-off commands (no installation needed)
16-
- **[Installation with uv add](#installation-with-uv-add)**: Use `uv add` to install sleap-nn as a dependency in a uv virtual env.
29+
- **[Installation with uv add](#installation-with-uv-add)**: Use `uv add` to install sleap-nn as a dependency in a uv virtual env. (useful for project-specific workspaces)
1730
- **[Installation with pip](#installation-with-pip)**: Use `pip` to install from pypi in a conda env. (Recommended to use with a conda env)
1831
- **[Installation from source](#installation-from-source)**: Use `uv sync` to install from source (for developmental purposes)
1932

@@ -35,14 +48,6 @@
3548

3649
### Platform-Specific Installation
3750

38-
!!! warning "Python 3.14 is not yet supported"
39-
`sleap-nn` currently supports **Python 3.11, 3.12, and 3.13**. **Python 3.14 is not yet tested or supported.** If you have Python 3.14 installed, you must specify the Python version in the install commands by adding `--python 3.13`.
40-
For example:
41-
```bash
42-
uv tool install --python 3.13 "sleap-nn[torch]" ...
43-
```
44-
Replace `...` with the rest of your install command as needed.
45-
4651
=== "Windows/Linux (CUDA)"
4752
```bash
4853
# CUDA 12.8
@@ -64,7 +69,7 @@
6469

6570
!!! info
6671
- For more information on which CUDA version to use for your system, see the [PyTorch installation guide](https://pytorch.org/get-started/locally/).
67-
The `--index` in the install command should match the CUDA version you need (e.g., `https://download.pytorch.org/whl/cuda118` for CUDA 11.8, `https://download.pytorch.org/whl/cuda128` for CUDA 12.8, etc.).
72+
The `--index` in the install command should match the CUDA version you need (e.g., `https://download.pytorch.org/whl/cu118` for CUDA 11.8, `https://download.pytorch.org/whl/cu128` for CUDA 12.8, etc.).
6873
- On macOS, MPS (Metal Performance Shaders) is automatically enabled for Apple Silicon acceleration.
6974

7075
### Verify installation
@@ -92,14 +97,6 @@ sleap-nn --help
9297

9398
### Platform-Specific Commands
9499

95-
!!! warning "Python 3.14 is not yet supported"
96-
`sleap-nn` currently supports **Python 3.11, 3.12, and 3.13**. **Python 3.14 is not yet tested or supported.** If you have Python 3.14 installed, you must specify the Python version in the install commands by adding `--python 3.13`.
97-
For example:
98-
```bash
99-
uvx --python 3.13 ...
100-
```
101-
Replace `...` with the rest of your install command as needed.
102-
103100
=== "Windows/Linux (CUDA)"
104101
```bash
105102
uvx --from "sleap-nn[torch]" --index https://download.pytorch.org/whl/cu128 --index https://pypi.org/simple sleap-nn train --config-name myconfig --config-dir /path/to/config_dir/
@@ -120,15 +117,9 @@ sleap-nn --help
120117

121118
!!! note
122119
- For more information on which CUDA version to use for your system, see the [PyTorch installation guide](https://pytorch.org/get-started/locally/).
123-
The `--index` in the install command should match the CUDA version you need (e.g., `https://download.pytorch.org/whl/cuda118` for CUDA 11.8, `https://download.pytorch.org/whl/cuda128` for CUDA 12.8, etc.).
120+
The `--index` in the install command should match the CUDA version you need (e.g., `https://download.pytorch.org/whl/cu118` for CUDA 11.8, `https://download.pytorch.org/whl/cu128` for CUDA 12.8, etc.).
124121
- On macOS, MPS (Metal Performance Shaders) is automatically enabled for Apple Silicon acceleration.
125122

126-
!!! tip "How uvx Works"
127-
- **Automatic Installation**: Downloads and installs sleap-nn with dependencies
128-
- **Isolated Environment**: Each command runs in a clean, temporary environment
129-
- **No Conflicts**: Won't interfere with your existing Python packages
130-
- **Uses recent pkgs**: Uses the latest version from PyPI
131-
132123
!!! note "uvx Installation"
133124
Because `uvx` installs packages fresh on every run, it's ideal for quick tests or use in remote environments. For regular use, you could install with [`uv tool install`](#installation-as-a-system-wide-tool-with-uv) or setting up a development environment with [`uv sync`](#installation-from-source) to avoid repeated downloads.
134125

@@ -138,14 +129,6 @@ sleap-nn --help
138129

139130
This method creates a dedicated project environment using uv's modern Python project management. It initializes a new project with `uv init`, creates an isolated virtual environment with `uv venv`, and adds sleap-nn as a dependency using `uv add`. To use all installed packages, you must run commands with `uv run` (e.g., `uv run sleap-nn train ...` or `uv run pytest ...`).
140131

141-
!!! warning "Python 3.14 is not yet supported"
142-
`sleap-nn` currently supports **Python 3.11, 3.12, and 3.13**. **Python 3.14 is not yet tested or supported.** `uv` will use the system-installed python by default. If you have python 3.14 installed on your system, then specify the Python version (<=3.13) in the venv command.
143-
For example:
144-
```bash
145-
uv venv --python 3.13 ...
146-
```
147-
Replace `...` with the rest of your install command as needed.
148-
149132
!!! note "Install and set-up uv"
150133
Step-1: Install [`uv`](https://github.com/astral-sh/uv) - a fast Python package manager:
151134
```bash
@@ -167,18 +150,34 @@ This method creates a dedicated project environment using uv's modern Python pro
167150
!!! tip "How `uv add` works"
168151
- When you run `uv init`, it creates a `pyproject.toml` file in your working directory to manage your project's dependencies.
169152
- When you use `uv add sleap-nn[torch]`, it adds `sleap-nn[torch]` as a dependency in your `pyproject.toml` and installs it in your virtual environment.
170-
- To add other packages, simply run `uv add <package>`. After adding new packages, you should run `uv sync` to update your environment with all dependencies specified in `pyproject.toml`.
153+
- To add other packages, simply run `uv add <package>`. After adding new packages, you should run `uv sync` to update your environment with all dependencies specified in `pyproject.toml`. (or `uv sync --upgrade` to update all dependencies)
171154
- To install a local package (such as a local clone of sleap-nn) in editable mode, use:
172155
```bash
173-
uv add --editable "./sleap-nn[torch]" ...
156+
uv add --editable "path/to/sleap-nn[torch]" ...
174157
```
175158
This is useful for development, as changes to the code are immediately reflected in your environment.
176159

160+
!!! warning "Windows: MarkupSafe Installation Issue"
161+
On **Windows**, you may encounter errors when running `uv add "sleap-nn[torch]" --index ...` due to an incompatibility with the MarkupSafe wheel (e.g., "failed to install MarkupSafe" or similar errors).
162+
Similar issues: [#11532](https://github.com/astral-sh/uv/issues/11532) and [#12620](https://github.com/astral-sh/uv/issues/12620).
163+
164+
**Workaround:**
165+
Before running `uv add "sleap-nn[torch]" ...` on Windows, manually install a compatible version of MarkupSafe:
166+
167+
```bash
168+
uv add git+https://github.com/pallets/[email protected]
169+
```
170+
171+
Then proceed with:
172+
173+
```bash
174+
uv add "sleap-nn[torch]" ...
175+
```
177176

178177
=== "Windows/Linux (CUDA)"
179178
```bash
180179
# CUDA 12.8
181-
uv add sleap-nn[torch] ---index https://download.pytorch.org/whl/cu128 --index https://pypi.org/simple
180+
uv add sleap-nn[torch] --index https://download.pytorch.org/whl/cu128 --index https://pypi.org/simple
182181

183182
# CUDA 11.8
184183
uv add sleap-nn[torch] --index https://download.pytorch.org/whl/cu118 --index https://pypi.org/simple
@@ -196,7 +195,7 @@ This method creates a dedicated project environment using uv's modern Python pro
196195

197196
!!! info
198197
- For more information on which CUDA version to use for your system, see the [PyTorch installation guide](https://pytorch.org/get-started/locally/).
199-
The `--index` in the install command should match the CUDA version you need (e.g., `https://download.pytorch.org/whl/cuda118` for CUDA 11.8, `https://download.pytorch.org/whl/cuda128` for CUDA 12.8, etc.).
198+
The `--index` in the install command should match the CUDA version you need (e.g., `https://download.pytorch.org/whl/cu118` for CUDA 11.8, `https://download.pytorch.org/whl/cu128` for CUDA 12.8, etc.).
200199
- On macOS, MPS (Metal Performance Shaders) is automatically enabled for Apple Silicon acceleration.
201200

202201
### Verify Installation
@@ -257,7 +256,7 @@ conda activate sleap-nn-env
257256

258257
!!! info
259258
- For more information on which CUDA version to use for your system, see the [PyTorch installation guide](https://pytorch.org/get-started/locally/).
260-
The `--extra-index-url` in the install command should match the CUDA version you need (e.g., `https://download.pytorch.org/whl/cuda118` for CUDA 11.8, `https://download.pytorch.org/whl/cuda128` for CUDA 12.8, etc.).
259+
The `--extra-index-url` in the install command should match the CUDA version you need (e.g., `https://download.pytorch.org/whl/cu118` for CUDA 11.8, `https://download.pytorch.org/whl/cu128` for CUDA 12.8, etc.).
261260
- On macOS, MPS (Metal Performance Shaders) is automatically enabled for Apple Silicon acceleration.
262261

263262

@@ -301,14 +300,6 @@ cd sleap-nn
301300

302301
#### 3. Install Dependencies
303302

304-
!!! warning "Python 3.14 is not yet supported"
305-
`sleap-nn` currently supports **Python 3.11, 3.12, and 3.13**. **Python 3.14 is not yet tested or supported.** `uv` will use the system-installed python by default. If you have python 3.14 installed on your system, then specify the Python version (<=3.13) in the installation command.
306-
For example:
307-
```bash
308-
uv sync --python 3.13 ...
309-
```
310-
Replace `...` with the rest of your install command as needed.
311-
312303
=== "Windows/Linux (CUDA 11.8)"
313304
```bash
314305
uv sync --extra dev --extra torch-cuda118
@@ -324,6 +315,14 @@ cd sleap-nn
324315
uv sync --extra dev --extra torch-cpu
325316
```
326317

318+
!!! tip "Upgrading All Dependencies"
319+
To ensure you have the latest versions of all dependencies, use the `--upgrade` flag with `uv sync`:
320+
```bash
321+
uv sync --extra dev --upgrade
322+
```
323+
This will upgrade all installed packages in your environment to the latest available versions compatible with your `pyproject.toml`.
324+
325+
327326
### Verify Installation
328327

329328
In your working dir (where you ran `uv sync`):

0 commit comments

Comments
 (0)