Wiki

Version 196 (Paul Carensac, 03/22/2016 10:24 am)

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 121 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}I - TODO%
12 121 Etienne Pallier
13 126 Etienne Pallier
 * installation sur windows
14 125 Etienne Pallier
15 126 Etienne Pallier
 * gitlab
16 1 Etienne Pallier
17 126 Etienne Pallier
 * séparation des BD Django et Pyros
18 125 Etienne Pallier
19 126 Etienne Pallier
 * intégration dans Eclipse
20 126 Etienne Pallier
21 174 Etienne Pallier
 * Intégration des modules Django déjà développés
22 125 Etienne Pallier
23 121 Etienne Pallier
24 3 Etienne Pallier
---
25 1 Etienne Pallier
26 140 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}I - DATABASE SCHEMA (v0.2.1)%
27 116 Etienne Pallier
28 116 Etienne Pallier
29 117 Etienne Pallier
{{thumbnail(PYROS_PDM_v021.png, size=300, title=Pyros data model)}}
30 121 Etienne Pallier
31 121 Etienne Pallier
32 121 Etienne Pallier
---
33 116 Etienne Pallier
34 141 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}II - Get the project (from gitlab)%
35 141 Etienne Pallier
36 141 Etienne Pallier
https://gitlab.irap.omp.eu/epallier/pyros
37 141 Etienne Pallier
38 161 Etienne Pallier
https://gitlab.irap.omp.eu/epallier/pyros.git
39 161 Etienne Pallier
40 161 Etienne Pallier
ssh git@gitlab.irap.omp.eu:epallier/pyros.git
41 141 Etienne Pallier
42 1 Etienne Pallier
43 169 Etienne Pallier
44 169 Etienne Pallier
h3. Get the project from the terminal
45 169 Etienne Pallier
46 174 Etienne Pallier
<pre>
47 1 Etienne Pallier
git clone https://gitlab.irap.omp.eu/epallier/pyros.git PYROS
48 1 Etienne Pallier
49 174 Etienne Pallier
(or also : git clone git@gitlab.irap.omp.eu:epallier/pyros.git)
50 174 Etienne Pallier
</pre>
51 174 Etienne Pallier
52 174 Etienne Pallier
If you just want a static copy of the project (without synchronization) just remove the .git/ folder :
53 174 Etienne Pallier
<pre>
54 174 Etienne Pallier
$ rm -r .git/
55 174 Etienne Pallier
</pre>
56 169 Etienne Pallier
57 169 Etienne Pallier
h3. Get the project from Eclipse
58 169 Etienne Pallier
59 169 Etienne Pallier
TODO:
60 169 Etienne Pallier
61 141 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}III - INSTALLATION%
62 2 Etienne Pallier
63 120 Etienne Pallier
64 120 Etienne Pallier
---
65 120 Etienne Pallier
66 184 Etienne Pallier
h3. Install MySql (only if necessary)
67 2 Etienne Pallier
68 49 Etienne Pallier
 * Linux Ubuntu
69 49 Etienne Pallier
<pre>
70 107 Paul Carensac
71 107 Paul Carensac
$ sudo apt-get install mysql-server
72 107 Paul Carensac
$ sudo apt-get install mysql-client
73 107 Paul Carensac
74 49 Etienne Pallier
</pre>
75 49 Etienne Pallier
76 49 Etienne Pallier
 * Linux CentOS
77 49 Etienne Pallier
<pre>
78 49 Etienne Pallier
TODO:
79 49 Etienne Pallier
$ sudo yum install mysql
80 49 Etienne Pallier
...
81 49 Etienne Pallier
</pre>
82 49 Etienne Pallier
83 49 Etienne Pallier
 * Mac OS X
84 1 Etienne Pallier
Install XAMPP
85 1 Etienne Pallier
(but you could also use the pre-installed Mac OS MySql)
86 177 Etienne Pallier
<pre>
87 177 Etienne Pallier
TODO:
88 49 Etienne Pallier
</pre>
89 1 Etienne Pallier
90 49 Etienne Pallier
 * Windows
91 177 Etienne Pallier
Install XAMPP
92 49 Etienne Pallier
<pre>
93 49 Etienne Pallier
TODO:
94 49 Etienne Pallier
</pre>
95 49 Etienne Pallier
96 49 Etienne Pallier
97 49 Etienne Pallier
---
98 1 Etienne Pallier
99 185 Etienne Pallier
h3. Install Python3.5 (only if necessary)
100 1 Etienne Pallier
101 11 Etienne Pallier
102 11 Etienne Pallier
 * Mac OS X :
103 1 Etienne Pallier
<pre>
104 183 Etienne Pallier
105 24 Etienne Pallier
1) Installer MacPort
106 24 Etienne Pallier
(TODO: doc)
107 24 Etienne Pallier
108 24 Etienne Pallier
2) Installer le "port" python35
109 1 Etienne Pallier
$ sudo port install python35
110 183 Etienne Pallier
111 1 Etienne Pallier
</pre>
112 1 Etienne Pallier
113 1 Etienne Pallier
 * Linux (Ubuntu) :
114 1 Etienne Pallier
<pre>
115 107 Paul Carensac
sudo add-apt-repository ppa:fkrull/deadsnakes
116 107 Paul Carensac
sudo apt-get update
117 107 Paul Carensac
sudo apt-get install python3.5
118 107 Paul Carensac
119 107 Paul Carensac
sudo pip install virtualenv
120 23 Etienne Pallier
</pre>
121 1 Etienne Pallier
122 1 Etienne Pallier
123 183 Etienne Pallier
 * Windows 10 :
124 183 Etienne Pallier
<pre>
125 187 Etienne Pallier
TODO:
126 183 Etienne Pallier
</pre>
127 3 Etienne Pallier
128 4 Etienne Pallier
---
129 5 Etienne Pallier
130 192 Etienne Pallier
h3. Create a Python3 virtual environment dedicated to the project (inside the project folder)
131 127 Etienne Pallier
132 131 Etienne Pallier
<pre>
133 1 Etienne Pallier
134 193 Etienne Pallier
$ mkdir private/
135 193 Etienne Pallier
136 133 Etienne Pallier
$ cd private/
137 3 Etienne Pallier
138 3 Etienne Pallier
$ which python3.5
139 3 Etienne Pallier
/opt/local/bin/python3.5
140 15 Etienne Pallier
141 127 Etienne Pallier
$ virtualenv-3.5 venv_py35_pyros -p /opt/local/bin/python3.5
142 3 Etienne Pallier
=> creates a venv_py35_pyros/ folder inside PYROS/private/
143 1 Etienne Pallier
144 131 Etienne Pallier
</pre>
145 1 Etienne Pallier
146 7 Etienne Pallier
---
147 3 Etienne Pallier
148 65 Etienne Pallier
h3. Activate the python virtual environment (from inside the project)
149 7 Etienne Pallier
150 55 Etienne Pallier
<pre>
151 1 Etienne Pallier
152 65 Etienne Pallier
$ pwd
153 134 Etienne Pallier
.../PYROS/private
154 1 Etienne Pallier
155 65 Etienne Pallier
$ source ./venv_py35_pyros/bin/activate
156 65 Etienne Pallier
157 3 Etienne Pallier
$ python -V
158 1 Etienne Pallier
Python 3.5.1
159 3 Etienne Pallier
160 3 Etienne Pallier
$ which pip
161 77 Etienne Pallier
.../PYROS/venv_py35_pyros/bin/pip
162 16 Etienne Pallier
163 194 Etienne Pallier
Upgrade pip to last version available:
164 3 Etienne Pallier
$ pip install --upgrade pip
165 3 Etienne Pallier
Collecting pip
166 3 Etienne Pallier
  Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB)
167 3 Etienne Pallier
Installing collected packages: pip
168 3 Etienne Pallier
  Found existing installation: pip 7.1.2
169 3 Etienne Pallier
    Uninstalling pip-7.1.2:
170 3 Etienne Pallier
      Successfully uninstalled pip-7.1.2
171 1 Etienne Pallier
Successfully installed pip-8.1.1
172 194 Etienne Pallier
173 194 Etienne Pallier
Upgrade wheel to last version available:
174 194 Etienne Pallier
$ pip install --upgrade wheel
175 194 Etienne Pallier
Collecting wheel
176 194 Etienne Pallier
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
177 194 Etienne Pallier
Installing collected packages: wheel
178 194 Etienne Pallier
  Found existing installation: wheel 0.24.0
179 194 Etienne Pallier
    Uninstalling wheel-0.24.0:
180 194 Etienne Pallier
      Successfully uninstalled wheel-0.24.0
181 194 Etienne Pallier
Successfully installed wheel-0.29.0
182 194 Etienne Pallier
183 55 Etienne Pallier
184 55 Etienne Pallier
</pre>
185 18 Etienne Pallier
186 27 Etienne Pallier
h3. Install needed python packages (from within the virtual environment)
187 18 Etienne Pallier
188 66 Etienne Pallier
First, be sure that the virtual environment is activated:
189 66 Etienne Pallier
<pre>
190 66 Etienne Pallier
$ python -V
191 66 Etienne Pallier
Python 3.5.1
192 66 Etienne Pallier
</pre>
193 66 Etienne Pallier
194 62 Etienne Pallier
 * *Automatic Installation of all packages*
195 62 Etienne Pallier
<pre>
196 90 Etienne Pallier
$ pip install -r REQUIREMENTS.txt
197 62 Etienne Pallier
</pre>
198 62 Etienne Pallier
199 93 Etienne Pallier
 * *Or, manual installation of each package*
200 62 Etienne Pallier
201 62 Etienne Pallier
  * *Install Django* :
202 32 Etienne Pallier
<pre>
203 3 Etienne Pallier
$ pip install django
204 3 Etienne Pallier
Collecting django
205 3 Etienne Pallier
  Downloading Django-1.9.4-py2.py3-none-any.whl (6.6MB)
206 3 Etienne Pallier
Installing collected packages: django
207 3 Etienne Pallier
Successfully installed django-1.9.4
208 3 Etienne Pallier
209 3 Etienne Pallier
$ pip install django-admin-tools
210 3 Etienne Pallier
Collecting django-admin-tools
211 3 Etienne Pallier
  Downloading django_admin_tools-0.7.2-py2.py3-none-any.whl (289kB)
212 3 Etienne Pallier
Installing collected packages: django-admin-tools
213 3 Etienne Pallier
Successfully installed django-admin-tools-0.7.2
214 3 Etienne Pallier
215 21 Etienne Pallier
$ pip install django-debug-toolbar
216 21 Etienne Pallier
Collecting django-debug-toolbar
217 21 Etienne Pallier
  Downloading django_debug_toolbar-1.4-py2.py3-none-any.whl (212kB)
218 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)
219 21 Etienne Pallier
Collecting sqlparse (from django-debug-toolbar)
220 21 Etienne Pallier
  Downloading sqlparse-0.1.19.tar.gz (58kB)
221 21 Etienne Pallier
Building wheels for collected packages: sqlparse
222 21 Etienne Pallier
  Running setup.py bdist_wheel for sqlparse ... done
223 21 Etienne Pallier
  Stored in directory: /Users/epallier/Library/Caches/pip/wheels/7b/d4/72/6011bb100dd5fc213164e4bbee13d4e03261dd54ce6a5de6b8
224 21 Etienne Pallier
Successfully built sqlparse
225 21 Etienne Pallier
Installing collected packages: sqlparse, django-debug-toolbar
226 21 Etienne Pallier
Successfully installed django-debug-toolbar-1.4 sqlparse-0.1.19
227 21 Etienne Pallier
228 21 Etienne Pallier
$ pip install django-extensions
229 21 Etienne Pallier
Collecting django-extensions
230 21 Etienne Pallier
  Downloading django_extensions-1.6.1-py2.py3-none-any.whl (202kB)
231 21 Etienne Pallier
Collecting six>=1.2 (from django-extensions)
232 21 Etienne Pallier
  Downloading six-1.10.0-py2.py3-none-any.whl
233 21 Etienne Pallier
Installing collected packages: six, django-extensions
234 21 Etienne Pallier
Successfully installed django-extensions-1.6.1 six-1.10.0
235 21 Etienne Pallier
236 21 Etienne Pallier
$ pip install django-suit
237 21 Etienne Pallier
Collecting django-suit
238 21 Etienne Pallier
  Downloading django-suit-0.2.18.tar.gz (587kB)
239 21 Etienne Pallier
Building wheels for collected packages: django-suit
240 1 Etienne Pallier
  Running setup.py bdist_wheel for django-suit ... done
241 1 Etienne Pallier
  Stored in directory: /Users/epallier/Library/Caches/pip/wheels/12/8b/9a/e02ab0ad9229881638aa040d47d77c8f562999533811927d41
242 1 Etienne Pallier
Successfully built django-suit
243 1 Etienne Pallier
Installing collected packages: django-suit
244 1 Etienne Pallier
Successfully installed django-suit-0.2.18
245 21 Etienne Pallier
246 32 Etienne Pallier
</pre>
247 32 Etienne Pallier
248 63 Etienne Pallier
  * *Install the web application server gunicorn (will be used in production instead of the dev django web server)* :
249 32 Etienne Pallier
<pre>
250 25 Etienne Pallier
$ pip install gunicorn
251 25 Etienne Pallier
Collecting gunicorn
252 25 Etienne Pallier
  Downloading gunicorn-19.4.5-py2.py3-none-any.whl (112kB)
253 21 Etienne Pallier
Installing collected packages: gunicorn
254 26 Etienne Pallier
Successfully installed gunicorn-19.4.5
255 1 Etienne Pallier
</pre>
256 1 Etienne Pallier
257 63 Etienne Pallier
  * *Install the python mysql client*:
258 32 Etienne Pallier
<pre>
259 32 Etienne Pallier
$ pip install mysqlclient
260 72 Etienne Pallier
...
261 72 Etienne Pallier
</pre>
262 33 Etienne Pallier
263 73 Etienne Pallier
   * => Issue under Mac OS X:
264 72 Etienne Pallier
<pre>
265 3 Etienne Pallier
$ pip install mysqlclient
266 3 Etienne Pallier
Collecting mysqlclient
267 1 Etienne Pallier
  Downloading mysqlclient-1.3.7.tar.gz (79kB)
268 22 Etienne Pallier
Building wheels for collected packages: mysqlclient
269 3 Etienne Pallier
  Running setup.py bdist_wheel for mysqlclient ... error
270 3 Etienne Pallier
271 1 Etienne Pallier
  ----------------------------------------
272 1 Etienne Pallier
  Failed building wheel for mysqlclient
273 1 Etienne Pallier
  Running setup.py clean for mysqlclient
274 1 Etienne Pallier
Failed to build mysqlclient
275 1 Etienne Pallier
Installing collected packages: mysqlclient
276 1 Etienne Pallier
  Running setup.py install for mysqlclient ... done
277 1 Etienne Pallier
Successfully installed mysqlclient-1.3.7
278 1 Etienne Pallier
279 1 Etienne Pallier
BOUH !!!
280 1 Etienne Pallier
281 1 Etienne Pallier
$ pip install --upgrade wheel
282 1 Etienne Pallier
Collecting wheel
283 1 Etienne Pallier
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
284 1 Etienne Pallier
Installing collected packages: wheel
285 1 Etienne Pallier
  Found existing installation: wheel 0.24.0
286 1 Etienne Pallier
    Uninstalling wheel-0.24.0:
287 1 Etienne Pallier
      Successfully uninstalled wheel-0.24.0
288 1 Etienne Pallier
Successfully installed wheel-0.29.0
289 1 Etienne Pallier
290 1 Etienne Pallier
$ pip uninstall mysqlclient
291 1 Etienne Pallier
292 1 Etienne Pallier
$ pip install mysqlclient
293 1 Etienne Pallier
Collecting mysqlclient
294 1 Etienne Pallier
  Using cached mysqlclient-1.3.7.tar.gz
295 1 Etienne Pallier
Building wheels for collected packages: mysqlclient
296 1 Etienne Pallier
  Running setup.py bdist_wheel for mysqlclient ... done
297 1 Etienne Pallier
  Stored in directory: /Users/epallier/Library/Caches/pip/wheels/9b/06/50/d11418c26cf8f2156b13d4363b5afde8e7e75ebb8540d0228d
298 1 Etienne Pallier
Successfully built mysqlclient
299 1 Etienne Pallier
Installing collected packages: mysqlclient
300 1 Etienne Pallier
Successfully installed mysqlclient-1.3.7
301 1 Etienne Pallier
302 1 Etienne Pallier
YES !!!
303 1 Etienne Pallier
304 1 Etienne Pallier
</pre>
305 1 Etienne Pallier
306 107 Paul Carensac
   * => Issues under Ubuntu:
307 107 Paul Carensac
<pre>
308 107 Paul Carensac
$ pip install mysqlclient
309 107 Paul Carensac
Collecting mysqlclient
310 107 Paul Carensac
  Downloading mysqlclient-1.3.7.tar.gz (79kB)
311 107 Paul Carensac
    100% |████████████████████████████████| 81kB 1.5MB/s
312 107 Paul Carensac
    Complete output from command python setup.py egg_info:
313 107 Paul Carensac
    /bin/sh: 1: mysql_config: not found
314 107 Paul Carensac
    Traceback (most recent call last):
315 107 Paul Carensac
      File "<string>", line 1, in <module>
316 107 Paul Carensac
    [...]
317 107 Paul Carensac
    ----------------------------------------
318 107 Paul Carensac
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-q6j4inuz/mysqlclient/
319 1 Etienne Pallier
320 108 Paul Carensac
BOUH !!!
321 108 Paul Carensac
322 107 Paul Carensac
$ sudo apt-get install libmysqlclient-dev
323 108 Paul Carensac
324 107 Paul Carensac
$ pip install mysqlclient
325 107 Paul Carensac
Collecting mysqlclient
326 107 Paul Carensac
  Using cached mysqlclient-1.3.7.tar.gz
327 107 Paul Carensac
Building wheels for collected packages: mysqlclient
328 107 Paul Carensac
  Running setup.py bdist_wheel for mysqlclient ... error
329 107 Paul Carensac
330 107 Paul Carensac
    _mysql.c:40:20: fatal error: Python.h: No such file or directory
331 107 Paul Carensac
     #include "Python.h"
332 107 Paul Carensac
                        ^
333 107 Paul Carensac
    compilation terminated.
334 107 Paul Carensac
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
335 107 Paul Carensac
    
336 107 Paul Carensac
    ----------------------------------------
337 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/
338 107 Paul Carensac
339 108 Paul Carensac
BOUH !!!
340 108 Paul Carensac
341 107 Paul Carensac
$ sudo apt-get install python3.5-dev
342 108 Paul Carensac
343 107 Paul Carensac
$ pip install mysqlclient
344 107 Paul Carensac
345 107 Paul Carensac
YES !!!
346 107 Paul Carensac
347 107 Paul Carensac
</pre>
348 12 Etienne Pallier
349 82 Etienne Pallier
 * *Set Requirements*
350 82 Etienne Pallier
351 82 Etienne Pallier
<pre>
352 82 Etienne Pallier
$ pip freeze > REQUIREMENTS.txt
353 82 Etienne Pallier
</pre>
354 12 Etienne Pallier
355 12 Etienne Pallier
---
356 28 Etienne Pallier
357 7 Etienne Pallier
h3. Create Django project pyros
358 38 Etienne Pallier
359 38 Etienne Pallier
<pre>
360 1 Etienne Pallier
361 83 Etienne Pallier
From inside the project:
362 83 Etienne Pallier
$ pwd
363 83 Etienne Pallier
.../PYROS/
364 83 Etienne Pallier
365 1 Etienne Pallier
$ django-admin startproject pyros
366 1 Etienne Pallier
367 149 Etienne Pallier
Rename the project folder "pyros/" as "src/"
368 149 Etienne Pallier
369 84 Etienne Pallier
$ mv pyros src
370 84 Etienne Pallier
371 1 Etienne Pallier
We have then this architecture:
372 86 Etienne Pallier
373 86 Etienne Pallier
PYROS
374 172 Etienne Pallier
├── REQUIREMENTS.txt
375 86 Etienne Pallier
├── private
376 137 Etienne Pallier
│   └── venv_py35_pyros
377 83 Etienne Pallier
├── public
378 83 Etienne Pallier
│   └── static
379 83 Etienne Pallier
├── src
380 83 Etienne Pallier
│   ├── manage.py
381 1 Etienne Pallier
│   ├── pyros
382 84 Etienne Pallier
│   │   ├── __init__.py
383 84 Etienne Pallier
│   │   ├── settings.py
384 84 Etienne Pallier
│   │   ├── urls.py
385 1 Etienne Pallier
│   │   └── wsgi.py
386 137 Etienne Pallier
387 142 Etienne Pallier
</pre>
388 3 Etienne Pallier
389 3 Etienne Pallier
390 1 Etienne Pallier
391 142 Etienne Pallier
392 142 Etienne Pallier
---
393 142 Etienne Pallier
394 142 Etienne Pallier
h3. Test the project
395 142 Etienne Pallier
396 142 Etienne Pallier
<pre>
397 142 Etienne Pallier
398 150 Etienne Pallier
$ cd src/
399 150 Etienne Pallier
400 1 Etienne Pallier
$ ./manage.py runserver
401 38 Etienne Pallier
(or gunicorn pyros.wsgi)
402 3 Etienne Pallier
==> http://localhost:8000
403 87 Etienne Pallier
...
404 87 Etienne Pallier
...
405 87 Etienne Pallier
Ctrl-c
406 87 Etienne Pallier
407 1 Etienne Pallier
</pre>
408 142 Etienne Pallier
409 142 Etienne Pallier
410 142 Etienne Pallier
411 142 Etienne Pallier
---
412 142 Etienne Pallier
413 142 Etienne Pallier
h3. The Web server
414 142 Etienne Pallier
415 142 Etienne Pallier
416 142 Etienne Pallier
Apache : gère tous les fichiers statiques (images, html…), et délègue les fichiers python au serveur django (par défaut)
417 142 Etienne Pallier
418 143 Etienne Pallier
Le fichier pyros/urls.py prend le relai pour tout ce qui est django
419 143 Etienne Pallier
420 142 Etienne Pallier
Le moteur web django sera soit du wsgi soit du unicorn
421 142 Etienne Pallier
422 142 Etienne Pallier
Par défaut, 1 seul worker, mais on peut en configurer plusieurs, l’idéal étant de faire "nb coeurs + 1" 
423 142 Etienne Pallier
(le worker maître qui fait le dispatching aux autres)
424 142 Etienne Pallier
425 142 Etienne Pallier
Frontend : Apache ou Ngininx
426 142 Etienne Pallier
427 142 Etienne Pallier
Backend : gunicorn (gère facilement des workers) ou uwsgi
428 142 Etienne Pallier
429 152 Etienne Pallier
<pre>
430 152 Etienne Pallier
$ gunicorn pyros.wsgi
431 1 Etienne Pallier
(à la place de manage runserver => A EVITER EN PROD)
432 152 Etienne Pallier
433 1 Etienne Pallier
Ou encore:
434 1 Etienne Pallier
435 152 Etienne Pallier
$ gunicorn --workers 5 library.wsgi
436 152 Etienne Pallier
</pre>
437 3 Etienne Pallier
438 42 Etienne Pallier
---
439 7 Etienne Pallier
440 3 Etienne Pallier
h3. Set Database engine as MySql
441 3 Etienne Pallier
442 41 Etienne Pallier
Edit src/pyros/settings.py
443 3 Etienne Pallier
444 3 Etienne Pallier
<pre>
445 3 Etienne Pallier
DATABASES = {
446 1 Etienne Pallier
    'default': {
447 3 Etienne Pallier
        'ENGINE': 'django.db.backends.mysql',
448 1 Etienne Pallier
        'NAME': 'pyros',
449 1 Etienne Pallier
        'USER': 'root',
450 1 Etienne Pallier
        'PASSWORD': ''
451 41 Etienne Pallier
    }
452 3 Etienne Pallier
}
453 7 Etienne Pallier
</pre>
454 3 Etienne Pallier
455 43 Etienne Pallier
---
456 7 Etienne Pallier
457 43 Etienne Pallier
h3. Import database into Django (with inspectdb)
458 3 Etienne Pallier
459 101 Etienne Pallier
From src/ :
460 94 Etienne Pallier
461 3 Etienne Pallier
<pre>
462 44 Etienne Pallier
$ ./manage.py inspectdb > models.py
463 94 Etienne Pallier
</pre>
464 44 Etienne Pallier
465 97 Etienne Pallier
Issue on Mac OS X:
466 3 Etienne Pallier
<pre>
467 3 Etienne Pallier
Traceback (most recent call last):
468 3 Etienne Pallier
  File "/Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 25, in <module>
469 3 Etienne Pallier
    import MySQLdb as Database
470 3 Etienne Pallier
  File "/Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/MySQLdb/__init__.py", line 19, in <module>
471 3 Etienne Pallier
    import _mysql
472 3 Etienne Pallier
ImportError: dlopen(/Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so, 2): Library not loaded: libmysqlclient.18.dylib
473 3 Etienne Pallier
  Referenced from: /Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so
474 3 Etienne Pallier
  Reason: image not found
475 3 Etienne Pallier
476 3 Etienne Pallier
=> BOUH !!!
477 3 Etienne Pallier
478 3 Etienne Pallier
LA SOLUTION EST ICI : http://stackoverflow.com/questions/6383310/python-mysqldb-library-not-loaded-libmysqlclient-18-dylib
479 3 Etienne Pallier
480 124 Etienne Pallier
Il suffit de faire ceci:
481 3 Etienne Pallier
482 124 Etienne Pallier
$ sudo mkdir -p /usr/local/lib   
483 124 Etienne Pallier
$ sudo ln -s /Applications/XAMPP/xamppfiles/lib/libmysql* /usr/local/lib/
484 124 Etienne Pallier
485 124 Etienne Pallier
Mais on peut aussi faire ceci:
486 3 Etienne Pallier
487 123 Etienne Pallier
Okay, so the offending file is /Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so
488 123 Etienne Pallier
489 123 Etienne Pallier
Next, figure out where _mysql.so thinks it should find libmysqlclient.18.dylib:
490 123 Etienne Pallier
491 1 Etienne Pallier
$ otool -L /Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so
492 10 Etienne Pallier
/Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so:
493 3 Etienne Pallier
	libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
494 3 Etienne Pallier
...
495 3 Etienne Pallier
496 123 Etienne Pallier
So, it's looking for libmysqlclient.18.dylib with no path information, let's fix that:
497 123 Etienne Pallier
498 1 Etienne Pallier
$ locate libmysqlclient.18.dylib
499 1 Etienne Pallier
/Applications/XAMPP/xamppfiles/lib/libmysqlclient.18.dylib
500 1 Etienne Pallier
/Library/SystemMigration/History/Migration-68137DFB-CB6A-4FBB-81E2-11BDB5D01E48/QuarantineRoot/usr/lib/libmysqlclient.18.dylib
501 1 Etienne Pallier
502 10 Etienne Pallier
$ sudo install_name_tool -change libmysqlclient.18.dylib /Applications/XAMPP/xamppfiles/lib/libmysqlclient.18.dylib /Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so
503 123 Etienne Pallier
504 123 Etienne Pallier
Now _mysql.so knows the full path to the library and everything works, regardless of environment variables.
505 10 Etienne Pallier
506 10 Etienne Pallier
$ otool -L /Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so
507 10 Etienne Pallier
/Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so:
508 3 Etienne Pallier
	/Applications/XAMPP/xamppfiles/lib/libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
509 1 Etienne Pallier
...
510 1 Etienne Pallier
511 3 Etienne Pallier
$ ./manage.py inspectdb > models.py
512 44 Etienne Pallier
513 3 Etienne Pallier
=> YES !!!
514 3 Etienne Pallier
</pre>
515 7 Etienne Pallier
516 3 Etienne Pallier
517 48 Etienne Pallier
---
518 7 Etienne Pallier
519 3 Etienne Pallier
h3. Create a Django application pyrosapp
520 3 Etienne Pallier
521 102 Etienne Pallier
From src/ :
522 98 Etienne Pallier
523 102 Etienne Pallier
<pre>
524 1 Etienne Pallier
$ ./manage.py startapp pyrosapp
525 1 Etienne Pallier
</pre>
526 1 Etienne Pallier
527 103 Etienne Pallier
We obtain this structure:
528 1 Etienne Pallier
529 103 Etienne Pallier
<pre>
530 104 Etienne Pallier
531 103 Etienne Pallier
PYROS/
532 172 Etienne Pallier
├── REQUIREMENTS.txt
533 1 Etienne Pallier
├── private/
534 153 Etienne Pallier
│   └── venv_py35_pyros/
535 153 Etienne Pallier
├── public/
536 153 Etienne Pallier
│   └── static/
537 103 Etienne Pallier
├── src/
538 103 Etienne Pallier
│   ├── manage.py
539 153 Etienne Pallier
│   ├── pyros/
540 103 Etienne Pallier
│   │   ├── __init__.py
541 103 Etienne Pallier
│   │   ├── __pycache__
542 103 Etienne Pallier
│   │   ├── settings.py
543 103 Etienne Pallier
│   │   ├── urls.py
544 103 Etienne Pallier
│   │   └── wsgi.py
545 153 Etienne Pallier
│   └── pyrosapp/
546 1 Etienne Pallier
│       ├── __init__.py
547 103 Etienne Pallier
│       ├── admin.py
548 103 Etienne Pallier
│       ├── apps.py
549 103 Etienne Pallier
│       ├── migrations
550 103 Etienne Pallier
│       ├── models.py
551 103 Etienne Pallier
│       ├── tests.py
552 103 Etienne Pallier
│       └── views.py
553 153 Etienne Pallier
554 103 Etienne Pallier
555 7 Etienne Pallier
</pre>
556 1 Etienne Pallier
557 7 Etienne Pallier
---
558 7 Etienne Pallier
559 3 Etienne Pallier
h3. Replace the default pyrosapp models.py with the inspectdb generated one
560 3 Etienne Pallier
561 105 Etienne Pallier
From src/ :
562 1 Etienne Pallier
563 105 Etienne Pallier
<pre>
564 105 Etienne Pallier
$ mv models.py pyrosapp/
565 105 Etienne Pallier
</pre>
566 3 Etienne Pallier
567 139 Paul Carensac
Add pyrosapp to the project's applications :
568 7 Etienne Pallier
569 139 Paul Carensac
Edit src/pyros/settings.py
570 1 Etienne Pallier
571 139 Paul Carensac
<pre>
572 139 Paul Carensac
INSTALLED_APPS = [
573 139 Paul Carensac
    'django.contrib.admin',
574 139 Paul Carensac
    'django.contrib.auth',
575 139 Paul Carensac
    'django.contrib.contenttypes',
576 139 Paul Carensac
    'django.contrib.sessions',
577 139 Paul Carensac
    'django.contrib.messages',
578 139 Paul Carensac
    'django.contrib.staticfiles',
579 139 Paul Carensac
    'pyrosapp',
580 139 Paul Carensac
]
581 139 Paul Carensac
</pre>
582 9 Etienne Pallier
583 47 Etienne Pallier
---
584 3 Etienne Pallier
585 145 Paul Carensac
h3. Fix and improve the pyrosapp models.py file (generated by inspectdb)
586 1 Etienne Pallier
587 145 Paul Carensac
Once models.py file generated, we need to delete the database and create an empty one :
588 145 Paul Carensac
 
589 145 Paul Carensac
<pre>
590 145 Paul Carensac
$ mysql -u root [-p (if password needed)]
591 106 Etienne Pallier
592 145 Paul Carensac
mysql> DROP DATABSE pyros
593 145 Paul Carensac
mysql> CREATE SCHEMA IF NOT EXISTS 'pyros' DEFAULT CHARACTER SET utf8;
594 1 Etienne Pallier
595 145 Paul Carensac
</pre>
596 1 Etienne Pallier
597 145 Paul Carensac
Then edit pyrosapp/models.py :
598 1 Etienne Pallier
599 145 Paul Carensac
 * Change 'managed = False' to 'managed = True' for every model
600 145 Paul Carensac
601 145 Paul Carensac
 * Change classes names to CamelCase (do not change the 'db_table = ...' lines). *Be careful* : it is needed to change all occurences :
602 145 Paul Carensac
603 145 Paul Carensac
    * NrtAlanysis
604 145 Paul Carensac
    * ScheduleHistory
605 145 Paul Carensac
    * ScientificProgram
606 145 Paul Carensac
    * SequenceType
607 145 Paul Carensac
    * SiteWatch
608 145 Paul Carensac
    * SiteWatchHistory
609 145 Paul Carensac
    * StrategyObs
610 154 Paul Carensac
    * UserLevel
611 145 Paul Carensac
    * WeatherWatch
612 145 Paul Carensac
    * WeatherWatchHistory
613 145 Paul Carensac
614 145 Paul Carensac
 * Change the deleting mode from 'models.DO_NOTHING' to 'models.CASCADE' for the following foreign keys :
615 145 Paul Carensac
616 145 Paul Carensac
    * Image.plan
617 145 Paul Carensac
    * Plan.album
618 145 Paul Carensac
    * Album.sequence
619 145 Paul Carensac
    * Sequence.request
620 145 Paul Carensac
621 145 Paul Carensac
 * Change the 'ForeignKey' liaisons to 'OneToOneField' liaisons (just replace ForeignKey by OneToOneField), and change deleting mode to 'models.CASCADE' for the following foreign keys :
622 145 Paul Carensac
623 145 Paul Carensac
    * Alert.request
624 145 Paul Carensac
    * Detector.device
625 145 Paul Carensac
    * Filter.device
626 145 Paul Carensac
    * Telescope.device
627 145 Paul Carensac
628 145 Paul Carensac
 * We need to redefine many to many relationships for the following classes :
629 145 Paul Carensac
630 145 Paul Carensac
    * User - ScientificProgram :
631 145 Paul Carensac
632 145 Paul Carensac
        * add 'users = models.ManyToManyField('User')' in ScientificProgram class
633 145 Paul Carensac
        * delete UserHasScientificProgram class
634 145 Paul Carensac
635 145 Paul Carensac
    * Sequence - ScheduleHistory
636 145 Paul Carensac
637 145 Paul Carensac
        * add 'sequences = models.ManyToManyField('Sequence')' in ScheduleHistory class
638 145 Paul Carensac
        * delete ScheduleHasSequences class
639 145 Paul Carensac
640 145 Paul Carensac
 * Finally apply modifications to the database :
641 145 Paul Carensac
642 145 Paul Carensac
<pre>
643 145 Paul Carensac
$ pwd
644 145 Paul Carensac
.../PYROS/src
645 145 Paul Carensac
$ python manage.py makemigrations pyrosapp
646 145 Paul Carensac
$ python manage.py migrate
647 145 Paul Carensac
</pre>
648 109 Etienne Pallier
649 109 Etienne Pallier
---
650 111 Etienne Pallier
651 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)%
652 155 Paul Carensac
653 155 Paul Carensac
---
654 155 Paul Carensac
655 155 Paul Carensac
h3. Back Office setup
656 155 Paul Carensac
657 155 Paul Carensac
 * Prerequisites in src/pyros/settings.py :
658 155 Paul Carensac
659 155 Paul Carensac
    * INSTALLED_APPS must (at least) contain :
660 155 Paul Carensac
661 155 Paul Carensac
        * django.contrib.admin
662 155 Paul Carensac
        * django.contrib.auth
663 155 Paul Carensac
        * django.contrib.contenttypes
664 155 Paul Carensac
        * django.contrib.sessions
665 155 Paul Carensac
666 155 Paul Carensac
    * MIDDLEWARES must (at least) contain :
667 155 Paul Carensac
668 155 Paul Carensac
        * django.contrib.sessions.middleware.SessionMiddleware
669 155 Paul Carensac
        * django.middleware.common.CommonMiddleware
670 155 Paul Carensac
        * django.contrib.auth.middleware.AuthenticationMiddleware
671 155 Paul Carensac
672 155 Paul Carensac
 * At least one 'python manage.py migrate' must have been executed
673 155 Paul Carensac
674 155 Paul Carensac
 * Create a superuser for the administration :
675 155 Paul Carensac
676 155 Paul Carensac
<pre>
677 155 Paul Carensac
$ python manage.py createsuperuser
678 155 Paul Carensac
</pre>
679 155 Paul Carensac
680 156 Paul Carensac
* For each app of the project, fill the admin.py file :
681 155 Paul Carensac
682 155 Paul Carensac
<pre>
683 155 Paul Carensac
from django.contrib import admin
684 155 Paul Carensac
from app.models import Model1, Model2
685 155 Paul Carensac
686 155 Paul Carensac
admin.site.register(Model1)
687 155 Paul Carensac
admin.site.register(Model2)
688 155 Paul Carensac
</pre>
689 155 Paul Carensac
690 155 Paul Carensac
*Reminder* : each application must be registered in the settings.py INSTALLED_APPS variable.
691 157 Paul Carensac
692 168 Paul Carensac
* For each model in models.py, add a '__str__()' method in order to identify the object on the back office. Example :
693 157 Paul Carensac
694 157 Paul Carensac
<pre>
695 157 Paul Carensac
class UserLevel(models.Model):
696 157 Paul Carensac
    name = models.CharField(max_length=45, blank=True, null=True)
697 157 Paul Carensac
    desc = models.TextField(blank=True, null=True)
698 157 Paul Carensac
    priority = models.IntegerField(blank=True, null=True)
699 157 Paul Carensac
    quota = models.FloatField(blank=True, null=True)
700 157 Paul Carensac
701 157 Paul Carensac
    class Meta:
702 157 Paul Carensac
        managed = True
703 157 Paul Carensac
        db_table = 'userlevel'
704 157 Paul Carensac
705 157 Paul Carensac
    def __str__(self):
706 163 Paul Carensac
        return (str(self.name))
707 157 Paul Carensac
</pre>
708 157 Paul Carensac
709 159 Paul Carensac
*Naming convention* : Use self.name when possible, the creation time/date otherwise. Example :
710 159 Paul Carensac
711 159 Paul Carensac
<pre>
712 159 Paul Carensac
class SiteWatch(models.Model):
713 159 Paul Carensac
    updated = models.DateTimeField(blank=True, null=True)
714 159 Paul Carensac
    lights = models.CharField(max_length=45, blank=True, null=True)
715 159 Paul Carensac
    dome = models.CharField(max_length=45, blank=True, null=True)
716 159 Paul Carensac
    doors = models.CharField(max_length=45, blank=True, null=True)
717 159 Paul Carensac
    temperature = models.FloatField(blank=True, null=True)
718 159 Paul Carensac
719 159 Paul Carensac
    class Meta:
720 159 Paul Carensac
        managed = True
721 159 Paul Carensac
        db_table = 'sitewatch'
722 159 Paul Carensac
723 159 Paul Carensac
    def __str__(self):
724 160 Paul Carensac
        return (str(self.updated))
725 159 Paul Carensac
</pre>
726 173 Etienne Pallier
727 196 Paul Carensac
* For each ForeignKey and ManyToManyField creation in models.py, add the 'related_name=[...]' named parameter, as in the following examples :
728 196 Paul Carensac
729 196 Paul Carensac
<pre>
730 196 Paul Carensac
class Sequence(models.Model):
731 196 Paul Carensac
    request = models.ForeignKey(Request, models.CASCADE, related_name="sequences")
732 196 Paul Carensac
    sequencetype = models.ForeignKey('SequenceType', models.DO_NOTHING, related_name="sequences")
733 196 Paul Carensac
    schedule = models.ForeignKey(Schedule, models.DO_NOTHING, related_name="sequences")
734 196 Paul Carensac
    name = models.CharField(max_length=45, blank=True, null=True)
735 196 Paul Carensac
    desc = models.TextField(blank=True, null=True)
736 196 Paul Carensac
    ...
737 196 Paul Carensac
738 196 Paul Carensac
class ScheduleHistory(models.Model):
739 196 Paul Carensac
    sequences = models.ManyToManyField('Sequence', related_name='schedulehistorys')
740 196 Paul Carensac
    created = models.DateTimeField(blank=True, null=True)
741 196 Paul Carensac
    ...
742 196 Paul Carensac
743 196 Paul Carensac
</pre>
744 196 Paul Carensac
745 176 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}V - INSTALLATION FROM THE BEGINNING (for dev only)%
746 173 Etienne Pallier
747 1 Etienne Pallier
748 176 Etienne Pallier
h3. How the git repository was created
749 176 Etienne Pallier
750 176 Etienne Pallier
*Git global setup:*
751 176 Etienne Pallier
752 176 Etienne Pallier
<pre>
753 176 Etienne Pallier
$ git config --global user.name "Etienne Pallier"
754 176 Etienne Pallier
$ git config --global user.email "etienne.pallier@irap.omp.eu"
755 176 Etienne Pallier
756 176 Etienne Pallier
$ cat ~/.gitconfig 
757 176 Etienne Pallier
[user]
758 176 Etienne Pallier
	name = Etienne Pallier
759 176 Etienne Pallier
	email = epallier@irap.omp.eu
760 176 Etienne Pallier
[http]
761 176 Etienne Pallier
	sslVerify = false
762 176 Etienne Pallier
</pre>
763 176 Etienne Pallier
764 176 Etienne Pallier
765 176 Etienne Pallier
*Create a new repository:*
766 176 Etienne Pallier
767 176 Etienne Pallier
<pre>
768 176 Etienne Pallier
$ cd PYROS/
769 176 Etienne Pallier
770 176 Etienne Pallier
Define files and folders to be ignored:
771 176 Etienne Pallier
$ vi .gitignore
772 176 Etienne Pallier
.DS_Store
773 176 Etienne Pallier
private
774 176 Etienne Pallier
__pycache__
775 176 Etienne Pallier
776 176 Etienne Pallier
$ touch README.md
777 176 Etienne Pallier
778 176 Etienne Pallier
$ git add README.md
779 176 Etienne Pallier
780 176 Etienne Pallier
$ git commit -m "first commit"
781 176 Etienne Pallier
782 176 Etienne Pallier
$ git remote add origin https://gitlab.irap.omp.eu/epallier/pyros.git
783 176 Etienne Pallier
784 176 Etienne Pallier
$ git push -u origin master
785 176 Etienne Pallier
786 176 Etienne Pallier
$ git add .
787 176 Etienne Pallier
788 176 Etienne Pallier
( if you want to be sure to add ALL files: 
789 176 Etienne Pallier
$ git add -A
790 176 Etienne Pallier
)
791 176 Etienne Pallier
792 176 Etienne Pallier
( if you wanted to remove added files, just type:
793 176 Etienne Pallier
$ git reset HEAD
794 176 Etienne Pallier
)
795 176 Etienne Pallier
796 176 Etienne Pallier
$ git commit -m "first full project commit"
797 176 Etienne Pallier
798 176 Etienne Pallier
$ git push -u origin master
799 176 Etienne Pallier
Counting objects: 43, done.
800 176 Etienne Pallier
Delta compression using up to 4 threads.
801 176 Etienne Pallier
Compressing objects: 100% (41/41), done.
802 176 Etienne Pallier
Writing objects: 100% (43/43), 575.13 KiB ö 0 bytes/s, done.
803 176 Etienne Pallier
Total 43 (delta 2), reused 0 (delta 0)
804 176 Etienne Pallier
To https://gitlab.irap.omp.eu/epallier/pyros.git
805 176 Etienne Pallier
   9c7128c..64501c9  master -> master
806 176 Etienne Pallier
Branch master set up to track remote branch master from origin.
807 176 Etienne Pallier
808 176 Etienne Pallier
$ git status
809 176 Etienne Pallier
On branch master
810 176 Etienne Pallier
Your branch is up-to-date with 'origin/master'.
811 176 Etienne Pallier
nothing to commit, working directory clean
812 176 Etienne Pallier
813 182 Etienne Pallier
</pre>
814 176 Etienne Pallier
815 191 Etienne Pallier
h3. Create the database
816 182 Etienne Pallier
817 182 Etienne Pallier
818 182 Etienne Pallier
 * Linux and Mac OS X:
819 182 Etienne Pallier
<pre>
820 182 Etienne Pallier
One liner:
821 182 Etienne Pallier
$ mysql -u root < pyros_create.sql
822 182 Etienne Pallier
823 182 Etienne Pallier
Or :
824 182 Etienne Pallier
$ mysql -u root
825 182 Etienne Pallier
mysql> create database pyros;
826 182 Etienne Pallier
mysql> use pyros;
827 182 Etienne Pallier
mysql> source pyros_create.sql;
828 182 Etienne Pallier
829 182 Etienne Pallier
(
830 182 Etienne Pallier
TODO:
831 182 Etienne Pallier
mysql> grant all on pyros.* to pyros@localhost identified by ‘pyros’;)
832 182 Etienne Pallier
mysql> flush privileges;
833 182 Etienne Pallier
)
834 176 Etienne Pallier
</pre>
835 182 Etienne Pallier
836 182 Etienne Pallier
837 182 Etienne Pallier
 * Windows:
838 182 Etienne Pallier
<pre>
839 182 Etienne Pallier
TODO: Use phpmyadmin ?
840 1 Etienne Pallier
</pre>
841 190 Etienne Pallier
842 190 Etienne Pallier
843 190 Etienne Pallier
844 190 Etienne Pallier
845 191 Etienne Pallier
h3. Create the project structure
846 190 Etienne Pallier
847 190 Etienne Pallier
<pre>
848 190 Etienne Pallier
$ mkdir PYROS
849 190 Etienne Pallier
</pre>
850 190 Etienne Pallier
851 190 Etienne Pallier
Example of a good organization :
852 190 Etienne Pallier
853 190 Etienne Pallier
1 project = N applis
854 190 Etienne Pallier
1 appli = N models
855 190 Etienne Pallier
A! L’appli est à côté du projet, PAS DEDANS,
856 190 Etienne Pallier
cela facilite la REUTILISATION
857 190 Etienne Pallier
(an appli can be part of many projects => reuse)
858 190 Etienne Pallier
1 appli = 1 Python module, organized for Django, by default = appli web (but not mandatory)
859 190 Etienne Pallier
860 190 Etienne Pallier
<pre>
861 190 Etienne Pallier
862 190 Etienne Pallier
MYPROJECT/
863 190 Etienne Pallier
	REQUIREMENTS.txt
864 190 Etienne Pallier
	src/
865 190 Etienne Pallier
		myproject/
866 190 Etienne Pallier
		appli1/
867 190 Etienne Pallier
		appli2/
868 190 Etienne Pallier
869 190 Etienne Pallier
		appliN/
870 190 Etienne Pallier
871 190 Etienne Pallier
	public/
872 190 Etienne Pallier
		static/
873 190 Etienne Pallier
874 190 Etienne Pallier
	private/
875 190 Etienne Pallier
		venv_py35_pyros/
876 190 Etienne Pallier
877 190 Etienne Pallier
</pre>
878 190 Etienne Pallier
879 190 Etienne Pallier
880 190 Etienne Pallier
Set needed folders:
881 190 Etienne Pallier
<pre>
882 190 Etienne Pallier
$ cd PYROS/
883 190 Etienne Pallier
$ mkdir private public
884 190 Etienne Pallier
$ mkdir public/static
885 190 Etienne Pallier
</pre>
886 190 Etienne Pallier
887 190 Etienne Pallier
888 190 Etienne Pallier
889 190 Etienne Pallier
---
890 182 Etienne Pallier
891 182 Etienne Pallier
892 182 Etienne Pallier
---