Installation of Chrysalio

Installing Required Packages

Before installing Chrysalio, you must install on your system the following packages:

$ sudo aptitude install python3-dev libffi-dev libzip-dev libxml2-dev libxslt1-dev build-essential

Installing a Virtual Environment

It is best practice to install Chrysalio into a “virtual” Python environment in order to obtain isolation from any “system” packages you’ve got installed in your current Python environment. This can be done by using venv module for Python 3.

To install a virtual environment, invoke the following commands for Python 3:

$ sudo aptitude install python3-venv
$ mkdir ~/bin
$ python3 -m venv ~/bin/virtualenv3
$ source ~/bin/virtualenv3/bin/activate
(virtualenv3)$ pip install -U pip setuptools wheel

If you are deploying Chrysalio on a server with Apache 2 or Nginx, replace in the preceding commands ~/bin/virtualenv3 by /usr/local/virtualenv3.

Setting up the Database

You need to create the database that matches your future configuration. We suppose the current user is super.

If you decide to use SQLite, you have nothing to do.

If you decide to use PostgreSQL (the recommended database), first install it:

$ sudo aptitude install postgresql libpq-dev
$ sudo su - postgres -c "createuser --superuser --pwprompt super"
$ createuser --no-superuser --pwprompt chrysalio
$ createdb -T template0 -E UTF-8 -O chrysalio Chrysalio

In the provided configuration, the password for PostgreSQL user is sesame.

Then, install the corresponding Python package:

$ source ~/bin/virtualenv3/bin/activate
(virtualenv3)$ pip install psycopg2-binary

If you decide to use MariaDB, install it:

$ sudo aptitude install mariadb-server libmariadb-dev libmariadbclient-dev
$ sudo mysql -u root mysql
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,INDEX,CREATE,DROP,ALTER ON *.* TO chrysalio@localhost IDENTIFIED BY 'sesame';
mysql> CREATE DATABASE Chrysalio;
mysql> QUIT;

Then, install the following Python package:

$ source ~/bin/virtualenv3/bin/activate
(virtualenv3)$ pip install mysqlclient

Installing the Application

Installation in Standard Mode

Install the latest stable released and all its requirements into your virtual Python environment:

$ source ~/bin/virtualenv3/bin/activate
(virtualenv3)$ pip install --extra-index-url=https://pypi.chrysal.io Chrysalio

Create a directory to deploy your instance and retrieve an example of configuration files:

$ mkdir Chrysalio
$ cd Chrysalio
$ wget https://pypi.chrysal.io/conf/Chrysalio.zip
$ unzip Chrysalio.zip
$ rm -f Chrysalio.zip

You can set up the application by tuning development.ini, production.ini or ciouser.ini. For instance, you can configure additional modules. See: Modules included in Chrysalio.

You could update your installation with the following command:

(virtualenv3)$ pip install --extra-index-url=https://pypi.chrysal.io -U Chrysalio

Installation in Development Mode

If you want to use the release still in development, follow these steps:

$ mkdir ~/Repositories
$ cd ~/Repositories
$ git clone https://gitlab.iinov.com/chrysalio/Chrysalio.git
$ source ~/bin/virtualenv3/bin/activate
(virtualenv3)$ cd ~/Repositories/Chrysalio
(virtualenv3)$ pip install -e ".[development]"

Populating and Running the Application

You need to use the ciopopulate console script to populate your database. To do so, type the following command:

(virtualenv3)$ ciopopulate development.ini

Then launch your server:

(virtualenv3)$ pserve development.ini
Starting server in PID xxxx.
Serving on http://0.0.0.0:6543

The running application will now be available at http://localhost:6543.

Testing the Application

To get this functionality working, you’ll need to install Chrysalio in development mode (see Installing the Application) with testing packages:

(virtualenv3)$ pip install -e ".[testing]"

Once pytest is installed, you can run the tests:

(virtualenv3)$ pytest --last-failed

To know if the coverage of the tests is complete, you can use the following command:

(virtualenv3)$ pytest --last-failed --cov --cov-report=term-missing

Or, scripts can help you:

(virtualenv3)$ ./pylint.sh
(virtualenv3)$ ./pytest.sh