- Install essential for pip
sudo apt-get install python-pip python-dev build-essential
- Install virtualenv
sudo pip install --upgrade virtualenv
- Create virtualenv
virtualenv ~/venv/<Your venv name>
- Install posgresql
sudo apt-get install postgresql postgresql-contrib
- Configure posgres db
sudo -u postgres psql
>>>CREATE USER admin WITH ENCRYPTED PASSWORD "12345678";
>>>CREATE DATABASE easyrest OWNER admin;
Or in /etc/postgresql/9.x/main/pg_hba.conf add lines to the bottom of the file:
local <dbname> <usrname> peer
host <dbname> <usrname> 127.0.0.1 md5 (edited)
and then restart postqresql service
sudo service postgresql restart
- Install pip packeges inside virtual env
(venv) pip install -e ".[testing]"
- Initialize db(with example data):
(venv) initialize_easyrest_db --fill development.ini
Drop and create empty database
(venv) initialize_easyrest_db --reset development.ini
Drop derivative models from Base
(venv) initialize_easyrest_db --drop development.ini
Reset and fill database
(venv) initialize_easyrest_db --reset --fill development.ini
--drop - Drop derivative models from Base
--fill - Create tables with test data (without create empty tables)
--reset - Drop and create empty database
- Run tests
(venv) pytest
- Run project
(venv) pserve --reload development.ini
alias envoff=`deactivate`
alias envon=`source ~/venv/<Your venv name>/bin/activate`
To run this you also need to specify your venv path in scripts/pyramidrun.sh and node version to use in scripts/noderun.sh (if you don't use nvm delete this line)
alias reston='gnome-terminal --tab -e "$(pwd)/scripts/pyramidrun.sh" --tab -e "$(pwd)/scripts/noderun.sh"'
- Install Docker and Docker Compose
- Change the database connection in the development.ini to this form.
# sqlalchemy.url = postgresql://localhost/easyrest?user=admin&password=123
# Connection for Docker environment
sqlalchemy.url = postgresql://admin:12345678@db/easyrest
- Change the server url in the development.ini to this form.
# listen = localhost:6543
# Url for Docker environment
listen = 0.0.0.0:6543
- Run
./smanager up
Services links:
- Make sure that you have python version 2.7
python --version
After installation Python append paths to python.exe (i.e. C:\Python27) and path to directory Scripts (i.e. C:\Python27\Scripts) in the PATH environment variable.
- If you are using Python 2 >=2.7.9 downloaded from python.org just make sure to upgrade pip:
python -m pip install -U pip
- Install virtualenv
pip install virtualenv
- Create virtualenv
virtualenv %VENV%
- Activate virtualenv
%VENV%\Scripts\activate
- Upgrade packaging tools in the virtual environment
(%VENV%) pip install --upgrade pip setuptools
- Install pip packeges inside virtual env
(%VENV%) pip install -e ".[testing]"
-
Install posgresql and create database
-
Initialize db
(%VENV%) initialize_easyrest_db --fill development.ini
Drop and create empty database
(%VENV%) initialize_easyrest_db --reset development.ini
Drop derivative models from Base
(%VENV%) initialize_easyrest_db --drop development.ini
Reset and fill database
(%VENV%) initialize_easyrest_db --reset --fill development.ini
--drop - Drop derivative models from Base
--fill - Create tables with test data (without create empty tables)
--reset - Drop and create empty database
- Run tests
(%VENV%) pytest
- Run project
pserve development.ini