# Advanced installation procedure

## Prerequisite

OpenLog requires the following general [dependencies](#direct-dependency-installations) to be met:

* Python 3.12
* Python packages: `psycopg2`,  `pandas`, `sqlalchemy`, `GeoAlchemy2`, `xplordb`, `pyqtgraph`, `numpy`
* Python optional package : `pyodbc`

When running a xplordb database, the following additional dependencies shall be met

* PostgreSQl 12+
* PostGIS 3

Once the [dependencies](#direct-dependency-installations) have been met, execute the following steps:

1. go to `Plugins` -> `Manage and Install Plugins` -> `All`
2. search for "OpenLog"
3. hit `Install Plugin`.

## Direct dependency installations

### Linux

```{Note}
Tested against Ubuntu >= 24.04
```

#### Python system [Linux]

To install Python, run:

```bash
sudo apt-get install python3 python3-pip
```

#### Python mandatory packages

OpenLog - QGIS Plugin depends on several python package :

| Package                | Website                                          | Description                                                                 |
|------------------------|--------------------------------------------------|-----------------------------------------------------------------------------|
| `pandas`               | <https://pandas.pydata.org/>                     | Data analysis and manipulation tool                                         |
| `psycopg2`             | <https://www.psycopg.org/docs/>                  | PostgreSQL database adapter for Python                                      |
| `sqlalchemy`           | <https://www.sqlalchemy.org/>                    | Python SQL Toolkit and Object Relation Mapper                               |
| `GeoAlchemy2`          | <https://geoalchemy-2.readthedocs.io/en/latest/> | sqlalchemy extension for spatial database (Spatialite and Postgis)          |
| `xplordb`              | <https://gitlab.com/geolandia/openlog/xplordb>   | Mineral Exploration Database template/ system for Postgres/PostGIS and QGIS |
| `pyqtgraph`            | <https://pyqtgraph.readthedocs.io/en/latest/>    | Data visualization library for Python using Qt GUI                          |
| `numpy`                | <https://numpy.org/>                             | Python package for scientific computation                                   |
| `pint`                 | <https://pint.readthedocs.io/en/stable/>         | Python package for units definition                                         |
| `setuptools`           | <https://setuptools.pypa.io/en/latest//>         | Python packaging toolkit                                                    |
| `chardet`              | <https://chardet.readthedocs.io/en/latest/>      | Character encoding                                                          |
| `pluggy`               | <https://pluggy.readthedocs.io/en/latest/>       | Function hooks                                                              |
| `py-machineid`         | <https://github.com/keygen-sh/py-machineid>      | Machine ID extraction                                                       |

To install the above packages with appropriate versions, run:

```bash
pip install --no-deps --force-reinstall --break-system-packages -U chevron "sqlalchemy>=1.4,<2.0" "GeoAlchemy2>=0.13.3,<0.14" "pyqtgraph>=0.13.3" "xplordb==0.13.8" "pint>=0.24.4" pluggy py-machineid mplstereonet flexparser flexcache typing-extensions platformdirs
```

#### Python optional packages

| Package  | Website                                 | Description                                                                                |
|----------|-----------------------------------------|--------------------------------------------------------------------------------------------|
| `pyodbc` | <https://github.com/mkleehammer/pyodbc> | Python module for ODBC database access, required by `sqlalchemy` for MSSQL database access |

To install the above packages, run:

```bash
pip install pyodbc
```

```{note}

In case the command above does not fully cover the dependencies, refer to the [req file](https://gitlab.com/geolandia/openlog/openlog-qgis-plugin/-/blob/main/requirements/development.txt?ref_type=heads) directly.

You may also need to install some external packages for compilation. See <https://github.com/mkleehammer/pyodbc/wiki/Install> for `pyodbc`.
```

### Windows

1. Run QGIS 3.42.x
2. go to `Plugins` -> `Python Console`
3. run the following command in the `Python Console` dock:

```bash
!pip install --no-deps --force-reinstall --break-system-packages -U chevron "sqlalchemy>=1.4,<2.0" "GeoAlchemy2>=0.13.3,<0.14" "pyqtgraph>=0.13.3" "xplordb==0.13.8" "pint>=0.24.4" pluggy py-machineid mplstereonet flexparser flexcache typing-extensions platformdirs
```