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 (
dev
) and optionally a Qt backend (pyqt
,pyside
).Note
If you only want to use napari and do not wish to develop napari itself, you can install napari on most macOS, Linux and Windows systems with Python 3.9-3.12 by following the steps on the instructions page.
napari supports different Qt backends and Qt versions. In this step, choose one of the following commands to install the developer tools and your preferred Qt backend.
For PyQt5, the default Qt backend, use:
pip install -e ".[pyqt,dev]" # (quotes only needed for zsh shell)
To use PySide2 instead of the PyQt5, use:
pip install -e ".[pyside,dev]" # (quotes only needed for zsh shell)
For PyOt6, use:
pip install -e ".[pyqt6,dev]" # (quotes only needed for zsh shell)
If you wish to install the developer tools only, use the following. Choose this option if you wish to install your Qt backend separately, such as if you already have a Qt backend installed or if you use an experimental backend like PySide6:
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.