Setting up a development installation#
In order to make changes to napari
, you will need to fork the
repository. If you are not familiar with git
, we recommend reading up on this guide.
Clone the forked repository to your local machine and change directories:
git clone https://github.com/your-username/napari.git cd napari
Set the
upstream
remote to the basenapari
repository:git remote add upstream https://github.com/napari/napari.git
If you haven’t already, create a development environment:
After installing
conda
, create an environment callednapari-env
with Python 3.10 and activate it.conda create -y -n napari-env -c conda-forge python=3.10 conda activate napari-env
After installing Python on your machine, create a virtual environment on your terminal and activate it. On Linux and macOS, you can run
python -m venv <path-to-env> source <path-to-env>/bin/activate
See the venv documentation for instructions on Windows.
Note
It is highly recommended to create a fresh environment when working with napari, to prevent issues with outdated or conflicting packages in your development environment.
Install the package in editable mode, along with all of the developer tools.
Note
If you only want to use napari, you can install it on most macOS, Linux and Windows systems with Python 3.9-3.12 by following the directions on the instructions page.
napari supports different Qt backends, and you can choose which one to install and use.
For example, for PyQt5, the default, you would use the following:
pip install -e ".[pyqt,dev]" # (quotes only needed for zsh shell)
If you want to use PySide2 instead, you would use:
pip install -e ".[pyside,dev]" # (quotes only needed for zsh shell)
Finally, if you already have a Qt backend installed or want to use an experimental one like Qt6 use:
pip install -e ".[dev]" # (quotes only needed for zsh shell)
Note that in this last case you will need to install your Qt backend separately.
We use
pre-commit
to format code withruff-format
and lint withruff
automatically prior to each commit. To minimize test errors when submitting pull requests, please installpre-commit
in your environment as follows:pre-commit install
Upon committing, your code will be formatted according to our
ruff-format
configuration.Code will also be linted to enforce the stylistic and logistical rules specified in the
[tool.ruff]
section of ourpyproject.toml
file. For information on any specificruff
error code, see the Ruff Rules. You may also wish to refer to the PEP 8 style guide.If you wish to tell the linter to ignore a specific line use the
# noqa
comment along with the specific error code (e.g.import sys # noqa: E402
) but please do not ignore errors lightly.
Now you are all set to start developing with napari.