Skip to content

Commit f19745e

Browse files
committed
Recommend uv for installation
1 parent 072614e commit f19745e

2 files changed

Lines changed: 78 additions & 78 deletions

File tree

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,24 @@ Current testing and maintenance work is focused on modern Linux, macOS, and Wind
3939

4040
## Installation
4141

42-
Install phy in a fresh Python 3.10+ environment:
42+
The recommended installation uses
43+
[`uv`](https://docs.astral.sh/uv/getting-started/installation/), which installs
44+
phy and its Python dependencies in an isolated environment:
4345

4446
```bash
45-
python -m pip install --upgrade pip
46-
pip install phy
47+
uv tool install --python 3.12 phy
48+
phy --version
4749
```
4850

4951
This installs the GUI runtime dependencies as part of the main package.
5052

51-
If you plan to use the legacy Kwik GUI, also install:
52-
53-
```bash
54-
pip install klusta klustakwik2
55-
```
53+
The legacy Kwik GUI needs a regular virtual environment because one of its
54+
dependencies requires special build handling. See the installation guide for
55+
the tested `uv` commands.
5656

5757
See the [installation guide](https://phy.readthedocs.io/en/latest/installation/)
58-
for Windows PowerShell, source checkouts, and installation verification.
58+
for instructions to install `uv`, legacy Kwik support, a `venv`/pip alternative,
59+
source checkouts, and installation verification.
5960

6061
## Quick start
6162

@@ -127,14 +128,13 @@ For a fresh editable installation using the latest commits of both phylib and ph
127128
```bash
128129
mkdir phy-source
129130
cd phy-source
130-
python3 -m venv .venv
131-
source .venv/bin/activate
132-
python -m pip install --upgrade pip
133131

134132
git clone https://github.com/cortex-lab/phylib.git
135133
git clone https://github.com/cortex-lab/phy.git
136-
python -m pip install --editable ./phylib
137-
python -m pip install --editable "./phy[dev]"
134+
135+
cd phy
136+
uv sync --dev
137+
uv pip install --editable ../phylib
138138
```
139139

140140
Windows PowerShell instructions, update commands, and verification of the exact commits are in the

docs/installation.md

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,31 @@ with the GUI.
66

77
## Install the stable release
88

9-
### Linux and macOS
9+
### Recommended: uv
1010

11-
Create and activate a virtual environment, then install phy from PyPI:
11+
Install [`uv`](https://docs.astral.sh/uv/getting-started/installation/) if it is
12+
not already available, then install phy as an isolated command-line tool:
13+
14+
```bash
15+
uv tool install --python 3.12 phy
16+
```
17+
18+
This command is the same on Linux, macOS, and Windows PowerShell. `uv` installs
19+
Python 3.12 if necessary, creates an environment dedicated to phy, and makes the
20+
`phy` command available without manually activating that environment.
21+
22+
To upgrade the stable installation later:
23+
24+
```bash
25+
uv tool upgrade phy
26+
```
27+
28+
### Alternative: venv and pip
29+
30+
If you prefer Python's standard environment tools, create and activate a virtual
31+
environment before installing phy.
32+
33+
On Linux and macOS:
1234

1335
```bash
1436
python3 -m venv phy-env
@@ -17,30 +39,25 @@ python -m pip install --upgrade pip
1739
python -m pip install phy
1840
```
1941

20-
If `python3` is not available but `python` is Python 3.10 or newer, use `python`
21-
in the first command.
22-
23-
### Windows PowerShell
42+
On Windows PowerShell:
2443

2544
```powershell
26-
py -3.10 -m venv phy-env
45+
py -3.12 -m venv phy-env
2746
.\phy-env\Scripts\Activate.ps1
2847
python -m pip install --upgrade pip
2948
python -m pip install phy
3049
```
3150

32-
You may choose another installed Python version from 3.10 onward. For example,
33-
use `py -3.12` for Python 3.12. If PowerShell prevents activation, either adjust
34-
its execution policy for your user or run the environment's Python directly:
51+
If PowerShell prevents activation, either adjust its execution policy for your
52+
user or run `.\phy-env\Scripts\python.exe -m pip install phy` followed by
53+
`.\phy-env\Scripts\phy.exe --version`.
3554

36-
```powershell
37-
.\phy-env\Scripts\python.exe -m pip install phy
38-
.\phy-env\Scripts\phy.exe --version
39-
```
55+
To upgrade this pip installation later, activate its environment and run
56+
`python -m pip install --upgrade phy`.
4057

4158
### Check the installation
4259

43-
With the environment active:
60+
After either installation method:
4461

4562
```bash
4663
phy --version
@@ -50,12 +67,6 @@ phy --help
5067
The first command prints the installed phy version. The second should list
5168
commands including `template-gui` and `template-describe`.
5269

53-
To upgrade the stable installation later:
54-
55-
```bash
56-
python -m pip install --upgrade phy
57-
```
58-
5970
## Install the latest phy and phylib source
6071

6172
Use this installation when testing an unreleased fix or developing phy. It
@@ -74,81 +85,65 @@ can live side by side.
7485
mkdir phy-source
7586
cd phy-source
7687

77-
python3 -m venv .venv
78-
source .venv/bin/activate
79-
python -m pip install --upgrade pip
80-
8188
git clone https://github.com/cortex-lab/phylib.git
8289
git clone https://github.com/cortex-lab/phy.git
8390

84-
python -m pip install --editable ./phylib
85-
python -m pip install --editable ./phy
91+
cd phy
92+
uv sync --dev
93+
uv pip install --editable ../phylib
8694
```
8795

88-
To run the phy test suite or build its documentation, install phy's development
89-
dependencies instead in the final command:
90-
91-
```bash
92-
python -m pip install --editable "./phy[dev]"
93-
```
96+
`uv sync` creates `phy/.venv`, installs phy editably, and installs the locked
97+
development dependencies. The final command replaces the released phylib
98+
package with the sibling source checkout.
9499

95100
### Windows PowerShell
96101

97102
```powershell
98103
New-Item -ItemType Directory phy-source
99104
Set-Location phy-source
100105
101-
py -3.10 -m venv .venv
102-
.\.venv\Scripts\Activate.ps1
103-
python -m pip install --upgrade pip
104-
105106
git clone https://github.com/cortex-lab/phylib.git
106107
git clone https://github.com/cortex-lab/phy.git
107108
108-
python -m pip install --editable .\phylib
109-
python -m pip install --editable .\phy
109+
Set-Location phy
110+
uv sync --dev
111+
uv pip install --editable ..\phylib
110112
```
111113

112-
For the phy test and documentation dependencies, replace the final command with:
113-
114-
```powershell
115-
python -m pip install --editable ".\phy[dev]"
116-
```
114+
These commands create the same editable development environment as the Linux and
115+
macOS instructions.
117116

118117
### Verify which source is running
119118

120119
Run the following commands from either operating system:
121120

122121
```bash
123-
phy --version
124-
python -m pip show phy phylib
125-
git -C phy log -1 --oneline
126-
git -C phylib log -1 --oneline
122+
uv run phy --version
123+
uv pip show phy phylib
124+
git log -1 --oneline
125+
git -C ../phylib log -1 --oneline
127126
```
128127

129-
For both packages, `pip show` should include an **Editable project location**
128+
For both packages, `uv pip show` should include an **Editable project location**
130129
pointing to the checkout you just cloned. The Git commands identify the exact
131130
commits being used. Development builds of phy may also show a development
132131
version or Git suffix in `phy --version`.
133132

134133
### Update both checkouts
135134

136-
Save or commit your own source changes before updating. From the `phy-source`
137-
directory, with the virtual environment active:
135+
Save or commit your own source changes before updating. From the `phy` checkout:
138136

139137
```bash
140-
git -C phylib pull --ff-only
141-
git -C phy pull --ff-only
142-
python -m pip install --upgrade --editable ./phylib
143-
python -m pip install --upgrade --editable ./phy
138+
git -C ../phylib pull --ff-only
139+
git pull --ff-only
140+
uv sync --dev
141+
uv pip install --editable ../phylib
144142
```
145143

146-
In Windows PowerShell, the same commands work; `./phylib` and `./phy` may also be
147-
written as `.\phylib` and `.\phy`.
148-
149-
Re-running the editable installation is worthwhile after an update because
150-
dependencies and package metadata can change even though ordinary Python source
151-
edits are already visible.
144+
In Windows PowerShell, `../phylib` may also be written as `..\phylib`.
145+
Re-running the sync picks up lockfile and package metadata changes, while the
146+
last command ensures the sibling phylib checkout remains installed.
152147

153148
## Start phy
154149

@@ -166,10 +161,15 @@ phy template-gui /path/to/output/params.py
166161
## Legacy Kwik support
167162

168163
The Template GUI is the recommended workflow for current template-based sorters.
169-
The legacy Kwik GUI needs additional packages:
164+
The legacy Kwik GUI needs additional packages. Install them in a separate
165+
uv-managed environment because `klustakwik2` needs NumPy, setuptools, and Cython
166+
available while it builds:
170167

171168
```bash
172-
python -m pip install klusta klustakwik2
169+
uv venv --python 3.12 phy-kwik-env
170+
uv pip install --python phy-kwik-env phy klusta cython
171+
uv pip install --python phy-kwik-env --no-build-isolation klustakwik2
173172
```
174173

175-
It can then be opened with `phy kwik-gui path/to/file.kwik`.
174+
Activate the environment using the command printed by `uv venv`. It can then be
175+
opened with `phy kwik-gui path/to/file.kwik`.

0 commit comments

Comments
 (0)