README.md 1.67 KB
Newer Older
Lauri Himanen's avatar
update  
Lauri Himanen committed
1 2
# __python-common__
This repository contains the common components for building a parser for the NOMAD project. The following instructions were tested on Ubuntu 14.04.
Lauri Himanen's avatar
Lauri Himanen committed
3

Lauri Himanen's avatar
update  
Lauri Himanen committed
4
# Quick Install
Lauri Himanen's avatar
Lauri Himanen committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18
The modules used for parser development are located under the 'nomadcore' package. You can setup this package in any way you like, but a simple installation script 'setup.py' is provided for ease of use. It will install the nomadcore package along with the needed dependencies. You can install the package in development mode by calling the terminal command

```sh
python setup.py develop --user
```

in the folder where setup.py is located. After this the package will be available to import by simply calling 

```python
import nomadcore
```

in python. The development mode also means that the latest version of the code is used, so any updates from git will automatically be available. You can install a static snapshot by using 'install' instead of 'develop'.

Lauri Himanen's avatar
update  
Lauri Himanen committed
19
# Manual install
Lauri Himanen's avatar
Lauri Himanen committed
20 21 22 23
This package depends on other python libraries which are declared in 'requirements.txt'. The requirements can be installed simply by calling the terminal command

```sh
pip install -r requirements.txt
Lauri Himanen's avatar
Update  
Lauri Himanen committed
24
```
Lauri Himanen's avatar
Lauri Himanen committed
25

Lauri Himanen's avatar
update  
Lauri Himanen committed
26 27 28
in the folder where the file is located.

In order to use the nomadcore package you have to add the directory to PYTHONPATH so that python knows where to look for it. This can be achieved temporarily by using a script like this
Lauri Himanen's avatar
Lauri Himanen committed
29 30 31 32 33 34 35 36 37

```python
import sys
dir = os.path.normpath("path/to/python-common/python"))
if not commonDir in sys.path:
    sys.path.insert(0, commonDir)
```

or the addition can be made permanent by adding the line
Lauri Himanen's avatar
Update  
Lauri Himanen committed
38

Lauri Himanen's avatar
Lauri Himanen committed
39 40
```sh
export PYTHONPATH="${PYTHONPATH}:/path/to/python-common/python"
Lauri Himanen's avatar
Update  
Lauri Himanen committed
41
```
Lauri Himanen's avatar
Lauri Himanen committed
42 43

to your ~/.bashrc file.