Skip to content

Commit c290799

Browse files
rtibblesclaude
andcommitted
Add Claude Code session hooks and update developer documentation
Session hooks auto-setup venv, install deps, and activate on start. Getting started docs updated for uv (replacing pyenv/pip/tox). AGENTS.md quick start updated. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1e3e84b commit c290799

3 files changed

Lines changed: 32 additions & 51 deletions

File tree

.claude/settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"hooks": {
3+
"SessionStart": [
4+
{
5+
"type": "command",
6+
"command": "if [ ! -d .venv ]; then uv sync --group dev --python 3.10; else uv sync --group dev; fi && pnpm install && source .venv/bin/activate && prek install"
7+
}
8+
]
9+
}
10+
}

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
## Quick Start
1010

1111
```bash
12-
pip install -r requirements/dev.txt # Python deps
12+
uv sync --group dev # Python deps + venv
1313
pnpm install # Node deps
1414
prek install # Required — commits fail without this
1515
export KOLIBRI_RUN_MODE=dev

docs/getting_started.rst

Lines changed: 21 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -66,52 +66,37 @@ Finally, add the Learning Equality repo as a remote called `upstream`. That way
6666
git checkout -t upstream/develop # Checkout the development branch
6767
6868
69-
Python and Pip
70-
~~~~~~~~~~~~~~
71-
72-
To develop on Kolibri, you'll need:
69+
Python and uv
70+
~~~~~~~~~~~~~
7371

74-
* Python 3.9 or higher (Note: Kolibri does not yet support Python 3.15 or above)
75-
* `pip <https://pypi.python.org/pypi/pip>`__
72+
Kolibri uses `uv <https://docs.astral.sh/uv/>`__ to manage Python versions and virtual environments. Install uv following the `official installation guide <https://docs.astral.sh/uv/getting-started/installation/>`__.
7673

77-
Managing Python installations can be quite tricky. We *highly* recommend using `pyenv <https://github.com/pyenv/pyenv>`__ or if you are more comfortable using a package manager, then package managers like `Homebrew <http://brew.sh/>`__ on Mac or ``apt`` on Debian for this.
74+
uv will automatically install the correct Python version when you set up the project — you do not need to install Python separately or use pyenv.
7875

79-
To install pyenv see the detailed instructions here :doc:`/howtos/installing_pyenv`.
80-
..note::
81-
If you are using a package manager, make sure to install a Python version compatible with Kolibri (3.9 or above, but below 3.15). If you're using `pyenv`, you can install it with a command like `pyenv install 3.9.9`.
82-
83-
.. warning::
84-
Never modify your system's built-in version of Python
76+
.. note::
77+
Direct development on Windows is not supported. If you're using a Windows machine, please set up your development environment using WSL (Windows Subsystem for Linux).
8578

8679
Python virtual environment
8780
~~~~~~~~~~~~~~~~~~~~~~~~~~
8881

89-
You should use a Python virtual environment to isolate the dependencies of your Python projects from each other and to avoid corrupting your system's Python installation.
90-
91-
There are many ways to set up Python virtual environments: You can use `pyenv-virtualenv <https://github.com/pyenv/pyenv-virtualenv>`__ as shown in the instructions below; you can also use `Virtualenv <https://virtualenv.pypa.io/en/latest/>`__, `Virtualenvwrapper <https://virtualenvwrapper.readthedocs.io/en/latest/>`__ `Pipenv <https://pipenv.readthedocs.io/en/latest/>`__, `Python 3 venv <https://docs.python.org/3/library/venv.html>`__, `Poetry <https://poetry.eustace.io>`__ etc.
92-
93-
.. note::
94-
Most virtual environments will require special setup for non-Bash shells such as Fish and ZSH.
95-
Direct development on Windows is not supported. If you're using a Windows machine, please set up your development environment using WSL (Windows Subsystem for Linux).
82+
uv automatically creates and manages a virtual environment in the ``.venv`` directory. Set up the project:
9683

97-
To setup and start using pyenv-virtualenv, follow the instructions here :doc:`/howtos/pyenv_virtualenv`.
84+
.. code-block:: bash
9885
99-
Once pyenv-virtualenv is installed, you can use the following commands to set up and use a virtual environment from within the Kolibri repo:
86+
uv sync --group dev # Creates venv, installs Python, installs all dev deps
10087
88+
Your virtual environment is now ready. Use ``uv run`` to execute commands within it:
10189

10290
.. code-block:: bash
10391
104-
pyenv virtualenv 3.9.9 kolibri-py3.9 # can also make an environment for other Python versions, e.g. 3.10
105-
pyenv activate kolibri-py3.9 # activates the virtual environment
106-
107-
Now, any commands you run will target your virtual environment rather than the global Python installation. To deactivate the virtualenv, simply run:
92+
uv run kolibri --version # Run kolibri CLI
93+
uv run pytest # Run tests
10894
95+
To activate the virtual environment in your shell (for interactive use):
10996

11097
.. code-block:: bash
11198
112-
pyenv deactivate
113-
114-
(Note that you'll want to leave it activated for the remainder of the setup process)
99+
source .venv/bin/activate # Linux/Mac
115100
116101
.. warning::
117102
Never install project dependencies using ``sudo pip install ...``
@@ -150,20 +135,11 @@ There are two environment variables you should plan to set:
150135
Install Python dependencies
151136
~~~~~~~~~~~~~~~~~~~~~~~~~~~
152137

153-
To install Kolibri project-specific dependencies make sure you're in the ``kolibri`` directory and your Python virtual environment is active. Then run:
138+
Python dependencies are installed automatically by ``uv sync --group dev`` above. To update dependencies after pulling new changes:
154139

155140
.. code-block:: bash
156141
157-
# required
158-
pip install -r requirements.txt --upgrade
159-
pip install -r requirements/dev.txt --upgrade
160-
pip install -e .
161-
162-
# optional
163-
pip install -r requirements/test.txt --upgrade
164-
pip install -r requirements/docs.txt --upgrade
165-
166-
Note that the ``--upgrade`` flags above can usually be omitted to speed up the process.
142+
uv sync --group dev
167143
168144
Install Node.js, pnpm and other dependencies
169145
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -430,12 +406,11 @@ We have a large number of reusable patterns, conventions, and components built i
430406
Updating documentation
431407
----------------------
432408

433-
First, install some additional dependencies related to building documentation output:
409+
First, install the documentation dependencies:
434410

435411
.. code-block:: bash
436412
437-
pip install -r requirements/docs.txt
438-
pip install -r requirements/build.txt
413+
uv sync --group docs
439414
440415
To make changes to documentation, edit the ``rst`` files in the ``kolibri/docs`` directory and then run:
441416

@@ -487,17 +462,13 @@ For more advanced usage, logical operators can also be used in wrapped strings,
487462
488463
pytest kolibri/auth/test/test_permissions -k "MembershipPermissionsTestCase and test_admin_can_delete_membership"
489464
490-
You can also use ``tox`` to setup a clean and disposable environment:
465+
You can run tests for a specific Python version using:
491466

492467
.. code-block:: bash
493468
494-
tox -e py3.4 # Runs tests with Python 3.4
495-
496-
To run Python tests for all environments, use simply ``tox``. This simulates what our CI also does on GitHub PRs.
497-
498-
.. note::
469+
uv run --python 3.9 pytest # Runs tests with Python 3.9
499470
500-
``tox`` reuses its environment when it is run again. If you add anything to the requirements, you will want to either delete the `.tox` directory, or run ``tox`` with the ``-r`` argument to recreate the environment
471+
CI runs tests across all supported Python versions automatically.
501472

502473

503474
Manual testing

0 commit comments

Comments
 (0)