README.md 2.12 KB
Newer Older
Lauri Himanen's avatar
update  
Lauri Himanen committed
1
# __python-common__
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19


This repository contains the common python files that are
part of the [NOMAD Laboratory](http://nomad-lab.eu).
The official version lives at

    git@gitlab.mpcdf.mpg.de:nomad-lab/python-common.git

you can browse it at

    https://gitlab.mpcdf.mpg.de/nomad-lab/python-common

Some things rely on having the nomad-meta-info checked out at the same level.
The simplest way to have this is to check out nomad-lab-base recursively:

    git clone --recursive git@gitlab.mpcdf.mpg.de:nomad-lab/nomad-lab-base.git

then this will be in python-common within it.
Lauri Himanen's avatar
Lauri Himanen committed
20

Lauri Himanen's avatar
update  
Lauri Himanen committed
21
# Quick Install
22 23 24

The following instructions were tested on Ubuntu 14.04.

Lauri Himanen's avatar
Lauri Himanen committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38
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
39
# Manual install
Lauri Himanen's avatar
Lauri Himanen committed
40 41 42 43
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
44
```
Lauri Himanen's avatar
Lauri Himanen committed
45

Lauri Himanen's avatar
update  
Lauri Himanen committed
46 47 48
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
49 50 51 52 53 54 55 56 57

```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
58

Lauri Himanen's avatar
Lauri Himanen committed
59 60
```sh
export PYTHONPATH="${PYTHONPATH}:/path/to/python-common/python"
Lauri Himanen's avatar
Update  
Lauri Himanen committed
61
```
Lauri Himanen's avatar
Lauri Himanen committed
62

63
to your ~/.bashrc file.