2022-05-02 16:14:18 +02:00
# Python API of the QMCkl library
2022-05-03 15:09:49 +02:00
2022-05-02 16:14:18 +02:00
## Requirements
2022-05-03 15:09:49 +02:00
- `setuptools`
2022-05-02 16:14:18 +02:00
- `numpy`
2022-05-03 15:09:49 +02:00
- `swig` (>= 4.0)
2022-05-02 16:14:18 +02:00
## Manual installation
2022-05-03 15:09:49 +02:00
1. Install the QMCkl library (see upstream instructions)
2022-05-04 16:41:16 +02:00
2. `./manual_install_qmckl.sh` which should do the following
3. Copy the produced `_qmckl.so` and `qmckl.py` files into your working directory and do not forget to `import qmckl` in your Python scripts
2022-05-03 15:09:49 +02:00
The second step executes the following under the hood:
2022-05-04 16:41:16 +02:00
1. `./build_qmckl.sh`
2. `<c-compiler> -I/usr/include/python3.8 -c -fPIC qmckl_wrap.c` to compile the wrapper code into an object file using the `<c-compiler>` (replace with your C compiler, e.g. `gcc` ) on your machine
3. `<c-compiler> -shared qmckl_wrap.o -lqmckl -o _qmckl.so` to produce the final C extension (this requires the `qmckl` library to be installed and present in the linking paths together with all its dependencies like `trexio` )
2022-05-03 15:09:49 +02:00
2022-05-02 16:14:18 +02:00
2022-05-03 15:09:49 +02:00
## Python-ic installation (recommended)
2022-05-02 16:14:18 +02:00
2022-05-03 15:09:49 +02:00
1. Install the QMCkl library (see upstream instructions)
2022-05-04 16:41:16 +02:00
2. `./pip_install_qmckl.sh`
2022-05-03 15:09:49 +02:00
2022-05-04 16:41:16 +02:00
The last step runs `./build_qmckl.sh` , copies the result into the `qmckl/` directory and
then runs `pip install .` to install the `qmckl` Python package in your environment.
2022-05-03 15:09:49 +02:00
## SWIG pre-processing
2022-05-04 16:41:16 +02:00
Both aforementioned steps call `build_qmckl.sh` script which does the following pre-processing for SWIG
2022-05-03 15:09:49 +02:00
1. Copy the latest `qmckl.h` file fron `include/` into the `src/` directory
2022-05-04 16:41:16 +02:00
2. `python process_header.py` to generate `qmckl_include.i` list of SWIG patterns
3. `swig -python -py3 -builtin -threads -o qmckl_wrap.c qmckl.i` to generate the SWIG wrapper code in C and `qmckl.py` module in Python.
**Note:** for this to work three files have to be present in the working directory: `qmckl.i` , `qmckl_include.i` and `numpy.i` .
2022-05-02 16:14:18 +02:00