« Previous - Version 122/374 (diff) - Next » - Current version
Etienne Pallier, 03/31/2016 05:58 pm


Project Installation

Project Development page : Project Development

HOWTO Format Redmine Wiki : http://www.redmine.org/projects/redmine/wiki/FrRedmineWikiFormatting


I - DATABASE SCHEMA (v0.2.1)

Error executing the thumbnail macro (Attachment PYROS_PDM_v021.png not found)


II - GET THE PYROS SOFTWARE

Software structure

Once you have fetched the project, you should obtain this structure:


PYROS/
├── install/
│   └── REQUIREMENTS.txt
│   └── INSTALLATION.txt
├── public/
│   └── static/
├── src/
│   ├── manage.py
│   ├── pyros/
│   │   ├── __init__.py
│   │   ├── __pycache__
│   │   ├── settings.py
│   │   ├── urls.py
│   │   └── wsgi.py
│   └── pyrosapp/
│       ├── __init__.py
│       ├── admin.py
│       ├── apps.py
│       ├── migrations
│       ├── models.py
│       ├── tests.py
│       └── views.py

Browse the code (from gitlab)

https://gitlab.irap.omp.eu/epallier/pyros/tree/master

Download it (static version, not synchronized)

You can download the current version of the software.

Go to https://gitlab.irap.omp.eu/epallier/pyros/tree/master

Click on "Download zip" on the up right hand corner.

Double-click on it to unzip it.

You should get a "pyros.git" folder.

In this documentation, this software folder will be referenced as "PYROS".

(you can rename "pyros.git" as "PYROS" if you want : "mv pyros.git PYROS")

Get it from GIT (dynamic version, synchronized)

(If you are using Windows, you must first get the git software, see below "Get git for Windows")

By getting the software from git, you will get a dynamically synchronized version,
which means that you will be able to update your version as soon as a new version is available
(with the command : "git pull").

  • From Eclipse : See below, section "NOTES FOR ECLIPSE USERS"
  • From the terminal
git clone https://gitlab.irap.omp.eu/epallier/pyros.git PYROS

(or also : git clone :epallier/pyros.git PYROS)

This creates a PYROS/ folder containing the project (with a .git/ subfolder for synchronization with the git repository)

(
If you just wanted a static copy of the project (without synchronization), just remove the .git/ folder:
"rm -r .git/"
)

(Windows only) : Get git for Windows

You can now use your git from the cmd or the graphic client !

III - INSTALLATION OF NEEDED DEPENDENCIES

Pyros has some dependencies that you need to install.
For this, you can read the INSTALL document from PYROS/install/
or go on reading this wiki page.


Install a database server (only if necessary)

If the MySql database server is already installed on your computer, skip this section

By default, Pyros uses Mysql, but this implies that you have to install the Mysql database server...

Thus, to make things easier, avoid Mysql installation by using Sqlite instead as the database server (which will need no installation at all) :

=> For this, just edit the file PYROS/src/pyros/settings.py and set MYSQL variable to False, and that's it. You can go to next section.

Now, if you really want to use Mysql (which is the default), you will need to install it (only if not already installed), so keep reading.

(Skip this if you are using Sqlite instead of MySql)

  • Linux Ubuntu
    
    $ sudo apt-get install mysql-server
    $ sudo apt-get install mysql-client
    
    
  • Linux CentOS
    TODO:
    $ sudo yum install mysql
    ...
    
  • Mac OS X
    Install XAMPP
    (but you could also use the pre-installed Mac OS MySql, or install MySql from macport)
    TODO:
    
  • Windows (tested with Windows 7)
Download and install the newest version on https://dev.mysql.com/downloads/installer/

Once installed, launch MySQL Installer. Clic on 'Add...' on the right.
In MySQLServers section, choose the newest, then clic on next.
Install and configure the server (just follow the installation guide).

Then launch mysql (via the Windows menu).

Install Python3 (only if necessary)

If Python 3 is already installed on your computer, skip this section

  • Mac OS X :
    • From binary (Mac OS native application)
      (TODO:)
    • From MacPort
      • a) install macport
        (TODO:)
      • b) install the "port" python35
        $ sudo port install python35
        
  • Linux (Ubuntu) :
    $ sudo add-apt-repository ppa:fkrull/deadsnakes
    $ sudo apt-get update
    $ sudo apt-get install python3.5
    
    $ sudo pip install virtualenv
    
  • Windows (tested with Windows 7) :
    (TODO: test with Windows 10)
    Go to https://www.python.org/downloads/windows/ , choose the wanted version
    On the wanted version’s page, download Windows x86 executable installer
    
    Run the executable
        * On the first page, check "Add python3.5 to PATH" 
        * Choose "Install now" option
    
    Open cmd (windows + R, cmd) :
     $ python -m pip install --upgrade pip
     $ pip install virtualenv
    

Install the needed Python dependencies and the database (within a Python virtual environment)

Go into the install/ folder and Run the install_requirements.sh script

  • Mac and Linux:
    $ cd .../PYROS/install/
    
    ./install_requirements.sh
    
    (Enter an username and a password for the superuser)
    
    
  • Windows:
    ...
    install_requirements.batch
    ...
    

If something goes wrong, install manually each package (see section "MANUAL INSTALLATION OF PYTHON PACKAGES, ONE BY ONE")


(Eclipse only) Set the Python3 virtual environment as the project interpreter

See below, in section "NOTES FOR ECLIPSE USERS"


IV - TEST

(TODO: run automatically from venv)

(Tests are classes declared in all apps' test.py file. The test classes inherit from django.test.TestCase)

You can run the tests suite, just to be sure that the software is well installed.

From Terminal


$ cd PYROS/

Activate the virtual env (if not already done):
$ source private/venv_py3_pyros/bin/activate

Now, run the tests:
$ cd src/
$ ./manage.py test
Ran 5 tests in 0.093s
OK

From Eclipse:

See below, in section "NOTES FOR ECLIPSE USERS"

Custom commands :

$ [./manage.py] test app.tests # Run tests for the application 'app'
$ [./manage.py] test app.tests.ModelTests # Run test methods declared in the class app.tests.ModelTests
$ [./manage.py] test app.tests.ModelTests.test_method # Only run the method test_method declared in app.tests.ModelTests


V - RUN

(TODO: run automatically from venv)

  • From the terminal

$ cd PYROS/

Activate the virtual env (if not already done):
$ source private/venv_py3_pyros/bin/activate

$ cd src/
$ ./manage.py runserver [PORT]
(or gunicorn pyros.wsgi)

Now, go to "http://localhost:8000/dashboard" in your browser

(and login as "pyros" with the password you entered during installation)

(Ctrl-c to stop)

  • From Eclipse : see below, in section "NOTES FOR ECLIPSE USERS"

NOTES FOR ECLIPSE USERS

0) Install Eclipse (if necessary)

Get the Eclipse version for Php

Install the plug-in pydev (via install new software, add http://pydev.org/updates)

Install the django template editor (via install new software, add http://eclipse.kacprzak.org/updates)

1) Deactivate CA certificate verification

Window -> Preferences -> Team -> git -> configuration -> Add entry

Key = http.sslVerify
Value = false

2) Fetch the project

File/Import project from git

Select repository source: Clone URI: https://gitlab.irap.omp.eu/epallier/pyros.git

Directory:
par défaut, il propose : /Users/epallier/git/pyros
mais on peut le mettre ailleurs (c'est ce que j'ai fait)

initial branch: master
remote name: origin

Import as general project

Project name: PYROS

3) Configure the project

The project is created. Now, you have to set it as a «PyDev » and a « Django » project.

clic droit sur le projet / PyDev / set as a PyDev project

clic droit sur le projet / PyDev / set as a Django project

clic droit sur le projet : on doit maintenant avoir un sous-menu Django

clic droit sur le dossier src / PyDev / set as source folder (add to PYTHONPATH)

clic droit sur projet / Properties / Pydev-Django :
- Django manage.py : src/manage.py
- Django settings module : pyros.settings

4) Set Code style

Window/Preferences : Pydev / Editor
- Auto Imports : uncheck « Do auto import »
- Code style:
- Locals … : camelCase
- Methods : camelCase() with first lower
- Code style / Code Formatter: activer « use autopep8.py for code formatting »
- Tabs : Tab length : 4

5) Now, once the Python3 virtual environment is installed (see above),
set it in Eclipse as the project interpreter:

Right clic on the project / Properties / PyDev - Interpreter/Grammar :
Grammar version : 3

Interpreter : click on « click here to configure an interpreter not listed »

click on « New... » :
- Interpreter name : venv_py35_pyros
- Interpreter executable : click on « Browse »
Select your virtualenv python35 executable (private/venv_py35_pyros/bin/python3.5)
click OK

Now, a last thing to do so that Pydev finds Django:

In the Python interpreters list, select your virtual env (venv_py35_pyros)

Click on the tab "Libraries"

clic on 'New folder', then select your virtualenv's lib/python3.5/site-packages folder

OK

Interpreter: select now venv_py35_pyros from the list

OK

6) Test

  • Right-clic on the project / Django / Run Django tests
  • Right-clic on the project / Django / Custom command / ...

7) Run

Right clic on project -> Django/Custom command/runserver

Error on Ubuntu :


Traceback (most recent call last):
  File "/home/carens_p/git/pyros/src/manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named 'django'

Project -> Properties -> Pydev interpreter -> Clic here to configure an interpreter not listed

select venv_py35_pyros

In Libraries, clic on 'New folder', then select your virtualenv's lib/python3.5/site-packages folder.

OK -> re-select venv_py35_pyros in 'Interpreter' dropdown menu

Then right clic on project -> Django/Custom command/runserver

check http://localhost:8000/



MANUAL INSTALLATION OF PYTHON PACKAGES ONE BY ONE

Create a Python3 virtual environment dedicated to the project (inside the project folder)


$ mkdir private/

$ cd private/

$ which python3.5 ("where python" for windows)
/opt/local/bin/python3.5

$ virtualenv venv_py35_pyros -p /opt/local/bin/python3.5
=> creates a venv_py35_pyros/ folder inside PYROS/private/


Activate the python virtual environment (from inside the project)


$ pwd
.../PYROS/private

$ source ./venv_py35_pyros/bin/activate (venv_py35_pyros/Scripts/activate on Windows)


Install needed python packages

Check that the virtual environment is activated

$ python -V
Python 3...

$ which pip
.../PYROS/venv_py35_pyros/bin/pip

Upgrade pip to last version available:

$ pip install --upgrade pip
Collecting pip
  Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB)
Installing collected packages: pip
  Found existing installation: pip 7.1.2
    Uninstalling pip-7.1.2:
      Successfully uninstalled pip-7.1.2
Successfully installed pip-8.1.1

Upgrade wheel to last version available:
$ pip install --upgrade wheel
Collecting wheel
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
Installing collected packages: wheel
  Found existing installation: wheel 0.24.0
    Uninstalling wheel-0.24.0:
      Successfully uninstalled wheel-0.24.0
Successfully installed wheel-0.29.0

Go into the install/ folder:

$ cd .../PYROS/install/

Install all the needed python packages at once:

$ pip install -r REQUIREMENTS.txt

If something goes wrong, install them one by one:

  • Install Django :
    $ pip install django
    Collecting django
      Downloading Django-1.9.4-py2.py3-none-any.whl (6.6MB)
    Installing collected packages: django
    Successfully installed django-1.9.4
    
    $ pip install django-admin-tools
    Collecting django-admin-tools
      Downloading django_admin_tools-0.7.2-py2.py3-none-any.whl (289kB)
    Installing collected packages: django-admin-tools
    Successfully installed django-admin-tools-0.7.2
    
    $ pip install django-debug-toolbar
    Collecting django-debug-toolbar
      Downloading django_debug_toolbar-1.4-py2.py3-none-any.whl (212kB)
    Requirement already satisfied (use --upgrade to upgrade): Django>=1.7 in ./venv_py35_pyros/lib/python3.5/site-packages (from django-debug-toolbar)
    Collecting sqlparse (from django-debug-toolbar)
      Downloading sqlparse-0.1.19.tar.gz (58kB)
    Building wheels for collected packages: sqlparse
      Running setup.py bdist_wheel for sqlparse ... done
      Stored in directory: /Users/epallier/Library/Caches/pip/wheels/7b/d4/72/6011bb100dd5fc213164e4bbee13d4e03261dd54ce6a5de6b8
    Successfully built sqlparse
    Installing collected packages: sqlparse, django-debug-toolbar
    Successfully installed django-debug-toolbar-1.4 sqlparse-0.1.19
    
    $ pip install django-extensions
    Collecting django-extensions
      Downloading django_extensions-1.6.1-py2.py3-none-any.whl (202kB)
    Collecting six>=1.2 (from django-extensions)
      Downloading six-1.10.0-py2.py3-none-any.whl
    Installing collected packages: six, django-extensions
    Successfully installed django-extensions-1.6.1 six-1.10.0
    
    $ pip install django-suit
    Collecting django-suit
      Downloading django-suit-0.2.18.tar.gz (587kB)
    Building wheels for collected packages: django-suit
      Running setup.py bdist_wheel for django-suit ... done
      Stored in directory: /Users/epallier/Library/Caches/pip/wheels/12/8b/9a/e02ab0ad9229881638aa040d47d77c8f562999533811927d41
    Successfully built django-suit
    Installing collected packages: django-suit
    Successfully installed django-suit-0.2.18
    
    
  • Install the django boostrap css package :
    $ pip install django-bootstrap3
    

    (==> 'bootstrap3' is then to be added as an application in settings.py -> INSTALLED_APPS)
  • Install the web application server gunicorn (will be used in production instead of the dev django web server) :
    $ pip install gunicorn
    Collecting gunicorn
      Downloading gunicorn-19.4.5-py2.py3-none-any.whl (112kB)
    Installing collected packages: gunicorn
    Successfully installed gunicorn-19.4.5
    
  • Install the python mysql client (not needed if you want to use sqlite):
    $ pip install mysqlclient
    ...
    
    • => Issue under Mac OS X:
      $ pip install mysqlclient
      Collecting mysqlclient
        Downloading mysqlclient-1.3.7.tar.gz (79kB)
      Building wheels for collected packages: mysqlclient
        Running setup.py bdist_wheel for mysqlclient ... error
      …
        ----------------------------------------
        Failed building wheel for mysqlclient
        Running setup.py clean for mysqlclient
      Failed to build mysqlclient
      Installing collected packages: mysqlclient
        Running setup.py install for mysqlclient ... done
      Successfully installed mysqlclient-1.3.7
      
      BOUH !!!
      
      $ pip install --upgrade wheel
      Collecting wheel
        Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
      Installing collected packages: wheel
        Found existing installation: wheel 0.24.0
          Uninstalling wheel-0.24.0:
            Successfully uninstalled wheel-0.24.0
      Successfully installed wheel-0.29.0
      
      $ pip uninstall mysqlclient
      
      $ pip install mysqlclient
      Collecting mysqlclient
        Using cached mysqlclient-1.3.7.tar.gz
      Building wheels for collected packages: mysqlclient
        Running setup.py bdist_wheel for mysqlclient ... done
        Stored in directory: /Users/epallier/Library/Caches/pip/wheels/9b/06/50/d11418c26cf8f2156b13d4363b5afde8e7e75ebb8540d0228d
      Successfully built mysqlclient
      Installing collected packages: mysqlclient
      Successfully installed mysqlclient-1.3.7
      
      YES !!!
      
      
    • => Issues under Ubuntu:
      $ pip install mysqlclient
      Collecting mysqlclient
        Downloading mysqlclient-1.3.7.tar.gz (79kB)
          Complete output from command python setup.py egg_info:
          /bin/sh: 1: mysql_config: not found
          Traceback (most recent call last):
            File "<string>", line 1, in <module>
          [...]
          ----------------------------------------
      Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-q6j4inuz/mysqlclient/
      
      BOUH !!!
      
      $ sudo apt-get install libmysqlclient-dev
      
      $ pip install mysqlclient
      Collecting mysqlclient
        Using cached mysqlclient-1.3.7.tar.gz
      Building wheels for collected packages: mysqlclient
        Running setup.py bdist_wheel for mysqlclient ... error
      …
          _mysql.c:40:20: fatal error: Python.h: No such file or directory
           #include "Python.h" 
                              ^
          compilation terminated.
          error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
      
          ----------------------------------------
      Command "/home/carens_p/pyros/venv_py35_pyros/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-k3klv92j/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gz242xxs-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/carens_p/pyros/venv_py35_pyros/include/site/python3.5/mysqlclient" failed with error code 1 in /tmp/pip-build-k3klv92j/mysqlclient/
      
      BOUH !!!
      
      $ sudo apt-get install python3.5-dev
      
      $ pip install mysqlclient
      
      YES !!!
      
      
    • => Issue under Windows
      Same message as the issue for Mac.
      
      Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient to download the newest mysqlclient wheel
      
      $ pip install path\to\mysqlclient\wheel
      
      No need to redo "pip install mysqlclient" 
      

PYROS_PDM_v021.png (306 KB) Etienne Pallier, 03/24/2016 12:49 pm

PYROS_DBM_V0_2_2.png (304 KB) Etienne Pallier, 08/11/2016 04:54 pm