Wiki

Version 299 (Etienne Pallier, 03/24/2016 12:50 pm)

1 1 Etienne Pallier
h1. Technical Documentation for the PYROS project (FGFT-CC)
2 1 Etienne Pallier
3 1 Etienne Pallier
4 1 Etienne Pallier
HOWTO Format Redmine Wiki : http://www.redmine.org/projects/redmine/wiki/FrRedmineWikiFormatting
5 1 Etienne Pallier
6 1 Etienne Pallier
{{>toc}}
7 1 Etienne Pallier
8 1 Etienne Pallier
9 121 Etienne Pallier
---
10 1 Etienne Pallier
11 297 Etienne Pallier
 * [[Project Installation]]
12 295 Etienne Pallier
13 297 Etienne Pallier
 * [[Project Development]]
14 291 Etienne Pallier
15 141 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}III - INSTALLATION%
16 2 Etienne Pallier
17 120 Etienne Pallier
18 120 Etienne Pallier
---
19 120 Etienne Pallier
20 184 Etienne Pallier
h3. Install MySql (only if necessary)
21 2 Etienne Pallier
22 49 Etienne Pallier
 * Linux Ubuntu
23 49 Etienne Pallier
<pre>
24 107 Paul Carensac
25 107 Paul Carensac
$ sudo apt-get install mysql-server
26 107 Paul Carensac
$ sudo apt-get install mysql-client
27 107 Paul Carensac
28 49 Etienne Pallier
</pre>
29 49 Etienne Pallier
30 49 Etienne Pallier
 * Linux CentOS
31 49 Etienne Pallier
<pre>
32 49 Etienne Pallier
TODO:
33 49 Etienne Pallier
$ sudo yum install mysql
34 49 Etienne Pallier
...
35 49 Etienne Pallier
</pre>
36 49 Etienne Pallier
37 49 Etienne Pallier
 * Mac OS X
38 1 Etienne Pallier
Install XAMPP
39 1 Etienne Pallier
(but you could also use the pre-installed Mac OS MySql)
40 177 Etienne Pallier
<pre>
41 177 Etienne Pallier
TODO:
42 49 Etienne Pallier
</pre>
43 1 Etienne Pallier
44 49 Etienne Pallier
 * Windows
45 243 Paul Carensac
46 1 Etienne Pallier
<pre>
47 243 Paul Carensac
Download and install the newest version on https://dev.mysql.com/downloads/installer/
48 243 Paul Carensac
49 243 Paul Carensac
Once installed, launch MySQL Installer. Clic on 'Add...' on the right.
50 243 Paul Carensac
In MySQLServers section, choose the newest, then clic on next.
51 243 Paul Carensac
Install and configure the server (just follow the installation guide).
52 243 Paul Carensac
53 243 Paul Carensac
Then launch mysql (via the Windows menu).
54 49 Etienne Pallier
</pre>
55 49 Etienne Pallier
56 49 Etienne Pallier
57 49 Etienne Pallier
---
58 1 Etienne Pallier
59 185 Etienne Pallier
h3. Install Python3.5 (only if necessary)
60 1 Etienne Pallier
61 11 Etienne Pallier
62 11 Etienne Pallier
 * Mac OS X :
63 1 Etienne Pallier
<pre>
64 183 Etienne Pallier
65 24 Etienne Pallier
1) Installer MacPort
66 24 Etienne Pallier
(TODO: doc)
67 24 Etienne Pallier
68 24 Etienne Pallier
2) Installer le "port" python35
69 1 Etienne Pallier
$ sudo port install python35
70 183 Etienne Pallier
71 1 Etienne Pallier
</pre>
72 1 Etienne Pallier
73 1 Etienne Pallier
 * Linux (Ubuntu) :
74 1 Etienne Pallier
<pre>
75 244 Paul Carensac
$ sudo add-apt-repository ppa:fkrull/deadsnakes
76 244 Paul Carensac
$ sudo apt-get update
77 244 Paul Carensac
$ sudo apt-get install python3.5
78 1 Etienne Pallier
79 244 Paul Carensac
$ sudo pip install virtualenv
80 1 Etienne Pallier
</pre>
81 1 Etienne Pallier
82 244 Paul Carensac
83 244 Paul Carensac
 * Windows 7 :
84 244 Paul Carensac
<pre>
85 244 Paul Carensac
Go to https://www.python.org/downloads/windows/ , choose the wanted version
86 244 Paul Carensac
On the wanted version’s page, download Windows x86 executable installer
87 244 Paul Carensac
88 244 Paul Carensac
Run the executable
89 244 Paul Carensac
    * On the first page, check "Add python3.5 to PATH"
90 244 Paul Carensac
    * Choose "Install now" option
91 245 Paul Carensac
92 245 Paul Carensac
Open cmd (windows + R, cmd) :
93 245 Paul Carensac
 $ python -m pip install --upgrade pip
94 245 Paul Carensac
 $ pip install virtualenv
95 244 Paul Carensac
</pre>
96 1 Etienne Pallier
97 183 Etienne Pallier
 * Windows 10 :
98 183 Etienne Pallier
<pre>
99 187 Etienne Pallier
TODO:
100 183 Etienne Pallier
</pre>
101 3 Etienne Pallier
102 4 Etienne Pallier
---
103 5 Etienne Pallier
104 192 Etienne Pallier
h3. Create a Python3 virtual environment dedicated to the project (inside the project folder)
105 127 Etienne Pallier
106 131 Etienne Pallier
<pre>
107 1 Etienne Pallier
108 193 Etienne Pallier
$ mkdir private/
109 193 Etienne Pallier
110 133 Etienne Pallier
$ cd private/
111 3 Etienne Pallier
112 246 Paul Carensac
$ which python3.5 ("where python" for windows)
113 3 Etienne Pallier
/opt/local/bin/python3.5
114 15 Etienne Pallier
115 127 Etienne Pallier
$ virtualenv-3.5 venv_py35_pyros -p /opt/local/bin/python3.5
116 3 Etienne Pallier
=> creates a venv_py35_pyros/ folder inside PYROS/private/
117 1 Etienne Pallier
118 131 Etienne Pallier
</pre>
119 1 Etienne Pallier
120 7 Etienne Pallier
---
121 3 Etienne Pallier
122 65 Etienne Pallier
h3. Activate the python virtual environment (from inside the project)
123 7 Etienne Pallier
124 55 Etienne Pallier
<pre>
125 1 Etienne Pallier
126 65 Etienne Pallier
$ pwd
127 134 Etienne Pallier
.../PYROS/private
128 1 Etienne Pallier
129 247 Paul Carensac
$ source ./venv_py35_pyros/bin/activate (venv_py35_pyros/Scripts/activate on Windows)
130 247 Paul Carensac
131 65 Etienne Pallier
132 3 Etienne Pallier
$ python -V
133 1 Etienne Pallier
Python 3.5.1
134 3 Etienne Pallier
135 3 Etienne Pallier
$ which pip
136 77 Etienne Pallier
.../PYROS/venv_py35_pyros/bin/pip
137 16 Etienne Pallier
138 194 Etienne Pallier
Upgrade pip to last version available:
139 3 Etienne Pallier
$ pip install --upgrade pip
140 3 Etienne Pallier
Collecting pip
141 3 Etienne Pallier
  Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB)
142 3 Etienne Pallier
Installing collected packages: pip
143 3 Etienne Pallier
  Found existing installation: pip 7.1.2
144 3 Etienne Pallier
    Uninstalling pip-7.1.2:
145 3 Etienne Pallier
      Successfully uninstalled pip-7.1.2
146 1 Etienne Pallier
Successfully installed pip-8.1.1
147 194 Etienne Pallier
148 194 Etienne Pallier
Upgrade wheel to last version available:
149 194 Etienne Pallier
$ pip install --upgrade wheel
150 194 Etienne Pallier
Collecting wheel
151 194 Etienne Pallier
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
152 194 Etienne Pallier
Installing collected packages: wheel
153 194 Etienne Pallier
  Found existing installation: wheel 0.24.0
154 194 Etienne Pallier
    Uninstalling wheel-0.24.0:
155 194 Etienne Pallier
      Successfully uninstalled wheel-0.24.0
156 194 Etienne Pallier
Successfully installed wheel-0.29.0
157 194 Etienne Pallier
158 55 Etienne Pallier
159 55 Etienne Pallier
</pre>
160 18 Etienne Pallier
161 267 Etienne Pallier
---
162 267 Etienne Pallier
163 212 Etienne Pallier
h3. Install the needed Python packages (from within the virtual environment)
164 18 Etienne Pallier
165 66 Etienne Pallier
First, be sure that the virtual environment is activated:
166 66 Etienne Pallier
<pre>
167 66 Etienne Pallier
$ python -V
168 66 Etienne Pallier
Python 3.5.1
169 66 Etienne Pallier
</pre>
170 66 Etienne Pallier
171 62 Etienne Pallier
 * *Automatic Installation of all packages*
172 62 Etienne Pallier
<pre>
173 90 Etienne Pallier
$ pip install -r REQUIREMENTS.txt
174 62 Etienne Pallier
</pre>
175 62 Etienne Pallier
176 93 Etienne Pallier
 * *Or, manual installation of each package*
177 62 Etienne Pallier
178 62 Etienne Pallier
  * *Install Django* :
179 32 Etienne Pallier
<pre>
180 3 Etienne Pallier
$ pip install django
181 3 Etienne Pallier
Collecting django
182 3 Etienne Pallier
  Downloading Django-1.9.4-py2.py3-none-any.whl (6.6MB)
183 3 Etienne Pallier
Installing collected packages: django
184 3 Etienne Pallier
Successfully installed django-1.9.4
185 3 Etienne Pallier
186 3 Etienne Pallier
$ pip install django-admin-tools
187 3 Etienne Pallier
Collecting django-admin-tools
188 3 Etienne Pallier
  Downloading django_admin_tools-0.7.2-py2.py3-none-any.whl (289kB)
189 3 Etienne Pallier
Installing collected packages: django-admin-tools
190 3 Etienne Pallier
Successfully installed django-admin-tools-0.7.2
191 3 Etienne Pallier
192 21 Etienne Pallier
$ pip install django-debug-toolbar
193 21 Etienne Pallier
Collecting django-debug-toolbar
194 21 Etienne Pallier
  Downloading django_debug_toolbar-1.4-py2.py3-none-any.whl (212kB)
195 21 Etienne Pallier
Requirement already satisfied (use --upgrade to upgrade): Django>=1.7 in ./venv_py35_pyros/lib/python3.5/site-packages (from django-debug-toolbar)
196 21 Etienne Pallier
Collecting sqlparse (from django-debug-toolbar)
197 21 Etienne Pallier
  Downloading sqlparse-0.1.19.tar.gz (58kB)
198 21 Etienne Pallier
Building wheels for collected packages: sqlparse
199 21 Etienne Pallier
  Running setup.py bdist_wheel for sqlparse ... done
200 21 Etienne Pallier
  Stored in directory: /Users/epallier/Library/Caches/pip/wheels/7b/d4/72/6011bb100dd5fc213164e4bbee13d4e03261dd54ce6a5de6b8
201 21 Etienne Pallier
Successfully built sqlparse
202 21 Etienne Pallier
Installing collected packages: sqlparse, django-debug-toolbar
203 21 Etienne Pallier
Successfully installed django-debug-toolbar-1.4 sqlparse-0.1.19
204 21 Etienne Pallier
205 21 Etienne Pallier
$ pip install django-extensions
206 21 Etienne Pallier
Collecting django-extensions
207 21 Etienne Pallier
  Downloading django_extensions-1.6.1-py2.py3-none-any.whl (202kB)
208 21 Etienne Pallier
Collecting six>=1.2 (from django-extensions)
209 21 Etienne Pallier
  Downloading six-1.10.0-py2.py3-none-any.whl
210 21 Etienne Pallier
Installing collected packages: six, django-extensions
211 21 Etienne Pallier
Successfully installed django-extensions-1.6.1 six-1.10.0
212 21 Etienne Pallier
213 21 Etienne Pallier
$ pip install django-suit
214 21 Etienne Pallier
Collecting django-suit
215 21 Etienne Pallier
  Downloading django-suit-0.2.18.tar.gz (587kB)
216 21 Etienne Pallier
Building wheels for collected packages: django-suit
217 1 Etienne Pallier
  Running setup.py bdist_wheel for django-suit ... done
218 1 Etienne Pallier
  Stored in directory: /Users/epallier/Library/Caches/pip/wheels/12/8b/9a/e02ab0ad9229881638aa040d47d77c8f562999533811927d41
219 1 Etienne Pallier
Successfully built django-suit
220 1 Etienne Pallier
Installing collected packages: django-suit
221 1 Etienne Pallier
Successfully installed django-suit-0.2.18
222 21 Etienne Pallier
223 32 Etienne Pallier
</pre>
224 32 Etienne Pallier
225 63 Etienne Pallier
  * *Install the web application server gunicorn (will be used in production instead of the dev django web server)* :
226 32 Etienne Pallier
<pre>
227 25 Etienne Pallier
$ pip install gunicorn
228 25 Etienne Pallier
Collecting gunicorn
229 25 Etienne Pallier
  Downloading gunicorn-19.4.5-py2.py3-none-any.whl (112kB)
230 21 Etienne Pallier
Installing collected packages: gunicorn
231 26 Etienne Pallier
Successfully installed gunicorn-19.4.5
232 1 Etienne Pallier
</pre>
233 1 Etienne Pallier
234 63 Etienne Pallier
  * *Install the python mysql client*:
235 32 Etienne Pallier
<pre>
236 32 Etienne Pallier
$ pip install mysqlclient
237 72 Etienne Pallier
...
238 72 Etienne Pallier
</pre>
239 33 Etienne Pallier
240 73 Etienne Pallier
   * => Issue under Mac OS X:
241 72 Etienne Pallier
<pre>
242 3 Etienne Pallier
$ pip install mysqlclient
243 3 Etienne Pallier
Collecting mysqlclient
244 1 Etienne Pallier
  Downloading mysqlclient-1.3.7.tar.gz (79kB)
245 22 Etienne Pallier
Building wheels for collected packages: mysqlclient
246 3 Etienne Pallier
  Running setup.py bdist_wheel for mysqlclient ... error
247 3 Etienne Pallier
248 1 Etienne Pallier
  ----------------------------------------
249 1 Etienne Pallier
  Failed building wheel for mysqlclient
250 1 Etienne Pallier
  Running setup.py clean for mysqlclient
251 1 Etienne Pallier
Failed to build mysqlclient
252 1 Etienne Pallier
Installing collected packages: mysqlclient
253 1 Etienne Pallier
  Running setup.py install for mysqlclient ... done
254 1 Etienne Pallier
Successfully installed mysqlclient-1.3.7
255 1 Etienne Pallier
256 1 Etienne Pallier
BOUH !!!
257 1 Etienne Pallier
258 1 Etienne Pallier
$ pip install --upgrade wheel
259 1 Etienne Pallier
Collecting wheel
260 1 Etienne Pallier
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
261 1 Etienne Pallier
Installing collected packages: wheel
262 1 Etienne Pallier
  Found existing installation: wheel 0.24.0
263 1 Etienne Pallier
    Uninstalling wheel-0.24.0:
264 1 Etienne Pallier
      Successfully uninstalled wheel-0.24.0
265 1 Etienne Pallier
Successfully installed wheel-0.29.0
266 1 Etienne Pallier
267 1 Etienne Pallier
$ pip uninstall mysqlclient
268 1 Etienne Pallier
269 1 Etienne Pallier
$ pip install mysqlclient
270 1 Etienne Pallier
Collecting mysqlclient
271 1 Etienne Pallier
  Using cached mysqlclient-1.3.7.tar.gz
272 1 Etienne Pallier
Building wheels for collected packages: mysqlclient
273 1 Etienne Pallier
  Running setup.py bdist_wheel for mysqlclient ... done
274 1 Etienne Pallier
  Stored in directory: /Users/epallier/Library/Caches/pip/wheels/9b/06/50/d11418c26cf8f2156b13d4363b5afde8e7e75ebb8540d0228d
275 1 Etienne Pallier
Successfully built mysqlclient
276 1 Etienne Pallier
Installing collected packages: mysqlclient
277 1 Etienne Pallier
Successfully installed mysqlclient-1.3.7
278 1 Etienne Pallier
279 1 Etienne Pallier
YES !!!
280 1 Etienne Pallier
281 1 Etienne Pallier
</pre>
282 1 Etienne Pallier
283 107 Paul Carensac
   * => Issues under Ubuntu:
284 107 Paul Carensac
<pre>
285 107 Paul Carensac
$ pip install mysqlclient
286 107 Paul Carensac
Collecting mysqlclient
287 107 Paul Carensac
  Downloading mysqlclient-1.3.7.tar.gz (79kB)
288 107 Paul Carensac
    100% |████████████████████████████████| 81kB 1.5MB/s
289 107 Paul Carensac
    Complete output from command python setup.py egg_info:
290 107 Paul Carensac
    /bin/sh: 1: mysql_config: not found
291 107 Paul Carensac
    Traceback (most recent call last):
292 107 Paul Carensac
      File "<string>", line 1, in <module>
293 107 Paul Carensac
    [...]
294 107 Paul Carensac
    ----------------------------------------
295 107 Paul Carensac
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-q6j4inuz/mysqlclient/
296 1 Etienne Pallier
297 108 Paul Carensac
BOUH !!!
298 108 Paul Carensac
299 107 Paul Carensac
$ sudo apt-get install libmysqlclient-dev
300 108 Paul Carensac
301 107 Paul Carensac
$ pip install mysqlclient
302 107 Paul Carensac
Collecting mysqlclient
303 107 Paul Carensac
  Using cached mysqlclient-1.3.7.tar.gz
304 107 Paul Carensac
Building wheels for collected packages: mysqlclient
305 107 Paul Carensac
  Running setup.py bdist_wheel for mysqlclient ... error
306 107 Paul Carensac
307 107 Paul Carensac
    _mysql.c:40:20: fatal error: Python.h: No such file or directory
308 107 Paul Carensac
     #include "Python.h"
309 107 Paul Carensac
                        ^
310 107 Paul Carensac
    compilation terminated.
311 107 Paul Carensac
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
312 107 Paul Carensac
    
313 107 Paul Carensac
    ----------------------------------------
314 107 Paul Carensac
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/
315 107 Paul Carensac
316 108 Paul Carensac
BOUH !!!
317 108 Paul Carensac
318 107 Paul Carensac
$ sudo apt-get install python3.5-dev
319 108 Paul Carensac
320 107 Paul Carensac
$ pip install mysqlclient
321 107 Paul Carensac
322 107 Paul Carensac
YES !!!
323 107 Paul Carensac
324 107 Paul Carensac
</pre>
325 12 Etienne Pallier
326 250 Paul Carensac
 * => Issue under Windows
327 250 Paul Carensac
<pre>
328 250 Paul Carensac
Same message as the issue for Mac.
329 250 Paul Carensac
330 250 Paul Carensac
Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient to download the newest mysqlclient wheel
331 250 Paul Carensac
332 250 Paul Carensac
$ pip install path\to\mysqlclient\wheel
333 250 Paul Carensac
334 250 Paul Carensac
No need to redo "pip install mysqlclient"
335 250 Paul Carensac
</pre>
336 250 Paul Carensac
337 12 Etienne Pallier
---
338 28 Etienne Pallier
339 262 Etienne Pallier
h3. (Eclipse only) Set the Python3 virtual environment as the project interpreter
340 260 Etienne Pallier
341 260 Etienne Pallier
clic droit sur projet / Properties / PyDev - Interpreter/Grammar :
342 260 Etienne Pallier
Grammar version : 3
343 276 Paul Carensac
344 260 Etienne Pallier
Interpreter : click on « click here to configure an interpreter not listed »
345 276 Paul Carensac
346 260 Etienne Pallier
click on « New » :
347 260 Etienne Pallier
- Interpreter name : venv_py35_pyros
348 260 Etienne Pallier
- Interpreter executable : click on « Browse »
349 260 Etienne Pallier
	Select your private/venv_py35_pyros/bin/python3.5 executable
350 260 Etienne Pallier
	click OK
351 260 Etienne Pallier
	click OK again
352 260 Etienne Pallier
353 260 Etienne Pallier
Interpreter: select now venv_py35_pyros from the list
354 260 Etienne Pallier
355 266 Etienne Pallier
---
356 266 Etienne Pallier
357 270 Etienne Pallier
h3. Run the project
358 142 Etienne Pallier
359 270 Etienne Pallier
TODO: more details... (notamment sur localhost:8000/admin)
360 1 Etienne Pallier
361 270 Etienne Pallier
h4. From the terminal
362 270 Etienne Pallier
363 142 Etienne Pallier
<pre>
364 142 Etienne Pallier
365 150 Etienne Pallier
$ cd src/
366 150 Etienne Pallier
367 1 Etienne Pallier
$ ./manage.py runserver
368 38 Etienne Pallier
(or gunicorn pyros.wsgi)
369 3 Etienne Pallier
==> http://localhost:8000
370 87 Etienne Pallier
...
371 87 Etienne Pallier
...
372 87 Etienne Pallier
Ctrl-c
373 87 Etienne Pallier
374 1 Etienne Pallier
</pre>
375 270 Etienne Pallier
376 270 Etienne Pallier
h4. From Eclipse
377 270 Etienne Pallier
378 286 Paul Carensac
Right clic on project -> Django/Custom command/runserver
379 286 Paul Carensac
380 286 Paul Carensac
Error on Ubuntu :
381 286 Paul Carensac
382 286 Paul Carensac
<pre>
383 286 Paul Carensac
384 286 Paul Carensac
Traceback (most recent call last):
385 286 Paul Carensac
  File "/home/carens_p/git/pyros/src/manage.py", line 8, in <module>
386 286 Paul Carensac
    from django.core.management import execute_from_command_line
387 286 Paul Carensac
ImportError: No module named 'django'
388 286 Paul Carensac
389 286 Paul Carensac
</pre>
390 286 Paul Carensac
391 286 Paul Carensac
Project -> Properties -> Pydev interpreter -> Clic here to configure an interpreter not listed
392 286 Paul Carensac
393 286 Paul Carensac
select venv_py35_pyros
394 286 Paul Carensac
395 286 Paul Carensac
In Libraries, clic on 'New folder', then select your virtualenv's lib/python3.5/site-packages folder.
396 286 Paul Carensac
397 286 Paul Carensac
OK -> re-select venv_py35_pyros in 'Interpreter' dropdown menu
398 286 Paul Carensac
399 286 Paul Carensac
Then right clic on project -> Django/Custom command/runserver
400 270 Etienne Pallier
401 270 Etienne Pallier
check http://localhost:8000/
402 142 Etienne Pallier
403 142 Etienne Pallier
404 142 Etienne Pallier
---
405 142 Etienne Pallier
406 156 Paul Carensac
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}IV - CONFIGURATION of the Django Back Office (administration interface)%
407 155 Paul Carensac
408 268 Etienne Pallier
[[django_backoffice_config|Configuration of the Django Back office (admin)]]
409 268 Etienne Pallier
410 211 Paul Carensac
411 229 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}V - INSTALLATION FROM THE BEGINNING (for dev only, history of the initial project creation)%
412 1 Etienne Pallier
413 236 Etienne Pallier
414 242 Etienne Pallier
[[pyros_install_from_start|Pyros installation from the beginning]]