Skip to content

Commit 53458ea

Browse files
committed
Confine the legacy Kwik constraints to the phy[kwik] extra
phy's own code uses no numpy API removed in 2.0, so the main dependency set moves to numpy>=1.23 with no upper bound and requires-python stays >=3.10. Regular users get numpy 2.x and Python 3.13. Everything the legacy Kwik GUI needs is confined to the kwik extra, which provides one self-contained, fully working setup -- opening .kwik files, curating them, and the recluster action (shift+ctrl+K, re-running KlustaKwik2): numpy>=1.23,<1.24 the last numpy the legacy klusta/klustakwik2 stack was written against; keeps the whole Kwik surface on tested ground. Caps the Kwik GUI at Python 3.10-3.11 (numpy 1.23 ships no cp312 wheels). setuptools<81 klusta/__init__.py imports pkg_resources, dropped in 81 six klusta declares no dependencies of its own The numpy pin is deliberately conservative rather than strictly required: reclustering runs on newer numpy (verified via klusta.launch.cluster(), the function the GUI action calls, on numpy 1.26.4), and even numpy 2 works once ndarray.tostring() -> .tobytes() in klusta/kwik/h5.py and klustakwik2/precomputations.py is fixed upstream. Pinning to <1.24 trades those newer versions for a single tested baseline; the cap can be relaxed later. Verified: phy[kwik] resolves on Python 3.11 (numpy 1.23.5, scipy 1.15.3) and the full KwikCreator -> KwikModel -> launch.cluster() round-trip passes.
1 parent a3c494a commit 53458ea

2 files changed

Lines changed: 89 additions & 4 deletions

File tree

README.md

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,74 @@ python -m pip install --upgrade pip
4646
pip install phy
4747
```
4848

49-
This installs the GUI runtime dependencies as part of the main package.
49+
This installs the GUI runtime dependencies as part of the main package. phy
50+
itself works with numpy 1.x and numpy 2.x; only the legacy Kwik GUI is
51+
constrained, and those constraints live in the `kwik` extra so that they apply
52+
to nobody else.
5053

51-
If you plan to use the legacy Kwik GUI, also install:
54+
### Installing from a git checkout
55+
56+
To run phy from this repository rather than from PyPI:
5257

5358
```bash
54-
pip install klusta klustakwik2
59+
conda create -n phy python=3.13 -y
60+
conda activate phy
61+
62+
git clone https://github.com/cortex-lab/phy.git
63+
cd phy
64+
pip install -e .
5565
```
5666

67+
`-e` (editable) means `git pull` updates your install with no reinstall step.
68+
Drop the `-e` for a plain copy. To install straight from GitHub without a local
69+
clone:
70+
71+
```bash
72+
pip install "phy @ git+https://github.com/cortex-lab/phy.git"
73+
```
74+
75+
### Kwik GUI dependencies
76+
77+
**The legacy Kwik GUI requires Python 3.10 or 3.11.** It depends on `klusta` and
78+
`klustakwik2`, both unmaintained since 2018, and the `kwik` extra pins
79+
`numpy>=1.23,<1.24` to keep the whole legacy stack on the numpy it was written
80+
against (see below). numpy 1.23 publishes no cp312 wheels, so Python 3.12 and
81+
3.13 are out for the Kwik GUI. Nothing here affects a plain `pip install phy`.
82+
83+
```bash
84+
pip install "phy[kwik]"
85+
```
86+
87+
On macOS and on Apple Silicon there are no `klustakwik2` wheels, and its
88+
`setup.py` imports numpy at build time, so build isolation has to be disabled:
89+
90+
```bash
91+
pip install "cython>=3.0"
92+
pip install --no-build-isolation klustakwik2
93+
pip install "phy[kwik]"
94+
```
95+
96+
The `kwik` extra enforces three constraints, all of them caused by the two legacy
97+
packages rather than by phy:
98+
99+
* `numpy>=1.23,<1.24` — the last numpy the legacy stack was written against. This
100+
keeps the entire Kwik surface on tested ground and gives one self-contained
101+
setup, at the cost of Python 3.12+ support. It is deliberately conservative:
102+
reclustering itself runs on newer numpy, and even numpy 2 works once two
103+
upstream call sites (`ndarray.tostring()` in `klusta/kwik/h5.py` and
104+
`klustakwik2/precomputations.py`, removed in numpy 2.0) are updated to
105+
`.tobytes()`. When those fixes are released upstream the cap can be relaxed.
106+
* `setuptools<81``klusta/__init__.py` imports `pkg_resources`, removed in 81.
107+
* `six``klusta` declares no dependencies of its own at all.
108+
109+
Under this extra, opening `.kwik` files, curating them, and the GUI's `recluster`
110+
action (`shift+ctrl+K`, which re-runs KlustaKwik2) all work.
111+
112+
Note that `klustakwik2` must also be *compiled* against the numpy major version
113+
it will run under: a later `pip install` that pulls a different numpy into the
114+
environment can break it with
115+
`ImportError: numpy.core.multiarray failed to import`.
116+
57117
## Quick start
58118

59119
Open the Template GUI on a spike sorting output directory containing `params.py`:

pyproject.toml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ classifiers = [
2222
"Programming Language :: Python :: 3.10",
2323
"Programming Language :: Python :: 3.11",
2424
"Programming Language :: Python :: 3.12",
25+
"Programming Language :: Python :: 3.13",
2526
]
2627
requires-python = ">=3.10"
2728

@@ -34,7 +35,7 @@ dependencies = [
3435
"joblib",
3536
"matplotlib",
3637
"mtscomp",
37-
"numpy",
38+
"numpy>=1.23",
3839
"pillow",
3940
"pip",
4041
"PyQt5>=5.15.11,<5.16",
@@ -55,6 +56,30 @@ Repository = "https://github.com/cortex-lab/phy"
5556
Documentation = "https://phy.readthedocs.io/en/latest/"
5657

5758
[project.optional-dependencies]
59+
# Legacy Kwik GUI. Both klusta and klustakwik2 are unmaintained (last releases
60+
# 2018) and constrain the environment in ways phy itself does not, so everything
61+
# legacy is confined to this extra to give one self-contained, fully working Kwik
62+
# setup (open, curate, and recluster) without holding back the main package:
63+
#
64+
# numpy>=1.23,<1.24 Pinned conservatively to the last numpy the legacy stack
65+
# was written against, so the whole Kwik surface -- not just the
66+
# parts phy exercises in CI -- stays on tested ground. This is
67+
# deliberately tighter than strictly required (reclustering itself
68+
# runs on newer numpy), and it is what caps the Kwik GUI at Python
69+
# 3.10-3.11: numpy 1.23 ships no cp312 wheels.
70+
# setuptools<81 klusta/__init__.py imports pkg_resources, dropped in 81.
71+
# six klusta declares no dependencies at all, and imports six.
72+
#
73+
# klustakwik2 has no wheels outside manylinux/win, and its setup.py imports numpy
74+
# at build time, so elsewhere it needs:
75+
# pip install --no-build-isolation klustakwik2
76+
kwik = [
77+
"klusta",
78+
"klustakwik2",
79+
"six",
80+
"numpy>=1.23,<1.24",
81+
"setuptools<81",
82+
]
5883
dev = [
5984
"Cython>=3.0",
6085
"pytest",

0 commit comments

Comments
 (0)