README.md 1.66 KB
Newer Older
1 2
# nGraph python binding

3
## Installation
4

5
### Install nGraph (Required)
6 7

```
8
Follow the [steps](http://ngraph.nervanasys.com/docs/latest/install.html) to build and install ngraph.
9 10
```

11
Clone the pybind repository
12 13

```
14 15
cd ngraph/python
git clone --recursive -b allow-nonconstructible-holders https://github.com/jagerman/pybind11.git
16 17
```

18
Set the environment variables
19 20

```
21 22 23 24
export NGRAPH_CPP_BUILD_PATH=$HOME/ngraph_dist
export LD_LIBRARY_PATH=$HOME/ngraph_dist/lib
export DYLD_LIBRARY_PATH=$HOME/ngraph_dist/lib # (Only needed on MacOS)
export PYBIND_HEADERS_PATH=pybind11
25 26
```

27
Install Wrapper (python binding)
28 29

```
30
python setup.py install
31 32 33 34 35 36 37 38 39
```

To run unit tests, first install additional required packages.

```
pip install -r test_requirements.txt
```

Then run a test.
40

41 42
```
pytest test/test_ops.py
43
pytest test/ngraph/
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
```

## Running tests with tox

[Tox](https://tox.readthedocs.io/) is a Python [virtualenv](https://virtualenv.pypa.io/) management and test command line tool. In our project it automates:

* running unit tests using [pytest](https://docs.pytest.org/)
* checking that code style is compliant with [PEP8](https://www.python.org/dev/peps/pep-0008/) using [Flake8](http://flake8.pycqa.org/)
* static type checking using [MyPy](http://mypy.readthedocs.io)
* testing across Python 2 and 3

Installing and running test with Tox:

    pip install tox
    tox

You can run tests using only Python 3 or 2 using the `-e` (environment) switch:

    tox -e py36
    tox -e py27

You can check styles in a particular code directory by specifying the path:

67
    tox ngraph/
68 69 70 71 72 73 74 75

In case of problems, try to recreate the virtual environments by deleting the `.tox` directory:

```
rm -rf .tox
tox
```