Requirements, Installation, and Testing

PyDelphin releases are available on PyPI and the source code is on GitHub. For most users, the easiest and recommended way of installing PyDelphin is from PyPI via pip, as it installs any required dependencies and makes the delphin command available (see PyDelphin at the Command Line). If you wish to inspect or contribute code, or if you need the most up-to-date features, PyDelphin may be used directly from its source files.

Requirements

PyDelphin works with Python 3.8 and higher, regardless of the platform. Certain features, however, may require additional dependencies or may be platform specific, as shown in the table below:

Module or Function

Dependencies

Notes

delphin.ace

ACE

Linux and Mac only

delphin.highlight

Pygments

delphin.web.client

requests

[web] extra

delphin.web.server

Falcon

[web] extra

delphin.codecs.dmrspenman

Penman

delphin.codecs.edspenman

Penman

delphin.repp

regex

[repp] extra

See Installing Extra Dependencies for information about installing with “extras”, including those needed for PyDelphin development (which are not listed in the table above).

Installing from PyPI

Install the latest releast from PyPI using pip:

[~]$ pip install pydelphin

If you already have an older version of PyDelphin installed, you can upgrade it by adding the --upgrade flag to the command.

Note

It is strongly recommended to use virtual environments to keep Python packages and dependencies confined to a specific environment. For more information, see here: https://packaging.python.org/tutorials/installing-packages/#creating-virtual-environments

Installing from Source

Clone the repository from GitHub to get the latest source code:

[~]$ git clone https://github.com/delph-in/pydelphin.git

Install from the source code using pip as before but give it the path to the repository instead of the name of the PyPI project:

[~]$ cd pydelphin/
[~/pydelphin]$ pip install .

Installing from source does not require internet access once the repository has been cloned, but it does require internet to install any dependencies. Also note that if the project directory is named pydelphin (the default) and you install from the directory above it, you mustn’t just use the directory name as this will cause pip to install from PyPI; instead, make it look path-like by prefixing it with ./ (i.e., pip install ./pydelphin).

For development, you may also want to use pip‘s -e option to install PyDelphin as “editable”, meaning it installs the dependencies but uses the local source files for PyDelphin’s code, otherwise changes you make to PyDelphin won’t be reflected in your (virtual) environment unless you reinstall PyDelphin.

Installing Extra Dependencies

Some features require dependencies beyond what the standard install provides. The purpose of keeping these dependencies optional is to reduce the install size for users who do not make use of the additional features.

If you need to use some of these features, such as delphin.web and delphin.repp, install the extra dependencies with pip as before but with an install parameter in brackets after pydelphin. For instance:

[~]$ pip install "pydelphin[web,repp]"

Without the install parameter, the PyDelphin code will still be installed but its dependencies will not be. The rest of PyDelphin will work but those features may raise an ImportError or issue a warning.

The extras that PyDelphin defines are as follows:

Extra

Description

[web]

Required for using the delphin.web client and server

[repp]

Optional for advanced regex features with delphin.repp

For Contributors

PyDelphin is built using Hatch, which also manages dependencies and commands for testing the code. You will need to install Hatch. Rather than installing PyDelphin as described above, use the hatch run command to test things, as follows:

[~/pydelphin]$ hatch run dev:lint # Linting [~/pydelphin]$ hatch run dev:typecheck # Type-checking [~/pydelphin]$ hatch run dev:test # Unit tests [~/pydelphin]$ hatch run docs:build # Build documentation [~/pydelphin]$ hatch build # build a source distribution and wheel

Hatch will create the dev and docs environments as appropriate, so you do not need to manage virtual environments yourself for these tasks.