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 versions 2.7 and 3.4+, regardless of the platform. Certain features, however, may require additional dependencies or may be platform specific, as shown in the table below:
Module | Dependencies | Notes |
---|---|---|
delphin.extra.highlight |
Pygments | |
delphin.extra.latex |
tikz-dependency | LaTeX package |
delphin.interfaces.ace |
ACE | Linux and Mac only |
delphin.interfaces.rest |
requests | |
delphin.mrs.compare |
NetworkX | |
delphin.mrs.penman |
Penman |
Installing from PyPI¶
Install the latest releast from PyPI using pip:
$ pip install pydelphin
If you already have PyDelphin installed, you can upgrade it by adding
the --upgrade
flag to the command.
Note
In general, it is a good idea 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
Running from Source¶
Clone the repository from GitHub to get the latest source code:
$ git clone https://github.com/delph-in/pydelphin.git
By default, cloning the git repository checks out the develop
branch. If you want to work in a difference branch (e.g., master
for
the code of the latest release), you’ll need to checkout
the
branch (e.g., $ git checkout master
).
In order to use PyDelphin from source, it will need to be importable by Python. If you are using PyDelphin as a library for your own project, you can adjust PYTHONPATH to point to PyDelphin’s top directory, e.g.:
$ PYTHONPATH=~/path/to/pydelphin/ python myproject.py
Also note that the dependencies of any PyDelphin features you use will need to be satisfied manually.
Alternatively, pip can install PyDelphin from the source directory instead of from PyPI, and it will detect and install the dependencies:
$ pip install ~/path/to/pydelphin/
Warning
The PyDelphin source code can be installed simply by running
$ setup.py install
, but this method is not recommended because
uninstalling PyDelphin and its dependencies becomes more difficult.
Running Unit Tests¶
PyDelphin’s unit tests are not distributed on PyPI, so if you wish to run the unit tests you’ll need to get the source code. The tests are written for pytest, so one way to run them is by installing pytest (for both Python 2 and 3), and running:
$ pytest --doctest-glob=tests/\*.md
A better way to run the tests is using tox:
$ tox
The tox utility manages the building of virtual
environments for testing, and it uses a configuration file (included
in PyDelphin’s sources) that specify how pytest should be
called. It can also run the tests for several different Python
versions. Note that simply running tox without any options
will attempt to test PyDelphin with every supported version of Python,
and it is likely that some of those versions are not installed on your
system. The -e
option to tox can specify the Python
version; e.g., the following runs the tests for Python versions 2.7
and 3.6:
$ tox -e py27,py36