Wiki
Version 97 (Etienne Pallier, 03/18/2016 02:27 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 | 1 | Etienne Pallier | |
10 | 3 | Etienne Pallier | --- |
11 | 1 | Etienne Pallier | |
12 | 57 | Etienne Pallier | h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}TODO% |
13 | 57 | Etienne Pallier | |
14 | 58 | Etienne Pallier | ajouter lien vers pyros.sql |
15 | 57 | Etienne Pallier | |
16 | 57 | Etienne Pallier | --- |
17 | 57 | Etienne Pallier | |
18 | 17 | Etienne Pallier | h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}I - INSTALLATION% |
19 | 2 | Etienne Pallier | |
20 | 51 | Etienne Pallier | h3. If necessary, install MySql |
21 | 2 | Etienne Pallier | |
22 | 49 | Etienne Pallier | * Linux Ubuntu |
23 | 49 | Etienne Pallier | <pre> |
24 | 49 | Etienne Pallier | TODO: |
25 | 49 | Etienne Pallier | $ sudo apt-get install mysql |
26 | 49 | Etienne Pallier | ... |
27 | 49 | Etienne Pallier | </pre> |
28 | 49 | Etienne Pallier | |
29 | 49 | Etienne Pallier | * Linux CentOS |
30 | 49 | Etienne Pallier | <pre> |
31 | 49 | Etienne Pallier | TODO: |
32 | 49 | Etienne Pallier | $ sudo yum install mysql |
33 | 49 | Etienne Pallier | ... |
34 | 49 | Etienne Pallier | </pre> |
35 | 49 | Etienne Pallier | |
36 | 49 | Etienne Pallier | * Mac OS X |
37 | 49 | Etienne Pallier | <pre> |
38 | 49 | Etienne Pallier | TODO: |
39 | 49 | Etienne Pallier | Install XAMPP |
40 | 49 | Etienne Pallier | (but you could also use the pre-installed Mac OS MySql) |
41 | 49 | Etienne Pallier | </pre> |
42 | 49 | Etienne Pallier | |
43 | 49 | Etienne Pallier | * Windows |
44 | 49 | Etienne Pallier | <pre> |
45 | 49 | Etienne Pallier | TODO: |
46 | 49 | Etienne Pallier | </pre> |
47 | 49 | Etienne Pallier | |
48 | 49 | Etienne Pallier | |
49 | 49 | Etienne Pallier | --- |
50 | 1 | Etienne Pallier | |
51 | 6 | Etienne Pallier | h3. Create database |
52 | 1 | Etienne Pallier | |
53 | 52 | Etienne Pallier | |
54 | 52 | Etienne Pallier | * Linux and Mac OS X: |
55 | 52 | Etienne Pallier | <pre> |
56 | 3 | Etienne Pallier | One liner: |
57 | 3 | Etienne Pallier | $ mysql -u root < pyros.sql |
58 | 1 | Etienne Pallier | |
59 | 3 | Etienne Pallier | Or : |
60 | 3 | Etienne Pallier | $ mysql -u root |
61 | 3 | Etienne Pallier | mysql> create database pyros; |
62 | 3 | Etienne Pallier | mysql> use pyros; |
63 | 3 | Etienne Pallier | mysql> source pyros.sql; |
64 | 1 | Etienne Pallier | |
65 | 3 | Etienne Pallier | ( |
66 | 3 | Etienne Pallier | TODO: |
67 | 3 | Etienne Pallier | mysql> grant all on pyros.* to pyros@localhost identified by ‘pyros’;) |
68 | 3 | Etienne Pallier | mysql> flush privileges; |
69 | 3 | Etienne Pallier | ) |
70 | 52 | Etienne Pallier | </pre> |
71 | 1 | Etienne Pallier | |
72 | 53 | Etienne Pallier | |
73 | 53 | Etienne Pallier | * Windows: |
74 | 52 | Etienne Pallier | <pre> |
75 | 52 | Etienne Pallier | TODO: Use phpmyadmin ? |
76 | 52 | Etienne Pallier | </pre> |
77 | 1 | Etienne Pallier | |
78 | 1 | Etienne Pallier | |
79 | 4 | Etienne Pallier | --- |
80 | 5 | Etienne Pallier | |
81 | 6 | Etienne Pallier | h3. Install python3.5 |
82 | 1 | Etienne Pallier | |
83 | 11 | Etienne Pallier | |
84 | 11 | Etienne Pallier | * Mac OS X : |
85 | 23 | Etienne Pallier | <pre> |
86 | 24 | Etienne Pallier | 1) Installer MacPort |
87 | 24 | Etienne Pallier | (TODO: doc) |
88 | 24 | Etienne Pallier | |
89 | 24 | Etienne Pallier | 2) Installer le "port" python35 |
90 | 1 | Etienne Pallier | $ sudo port install python35 |
91 | 23 | Etienne Pallier | </pre> |
92 | 1 | Etienne Pallier | |
93 | 11 | Etienne Pallier | * Linux (Ubuntu) : |
94 | 23 | Etienne Pallier | <pre> |
95 | 1 | Etienne Pallier | $ sudo apt-get ... |
96 | 23 | Etienne Pallier | </pre> |
97 | 1 | Etienne Pallier | |
98 | 5 | Etienne Pallier | |
99 | 3 | Etienne Pallier | |
100 | 4 | Etienne Pallier | --- |
101 | 5 | Etienne Pallier | |
102 | 13 | Etienne Pallier | h3. Create project dir |
103 | 13 | Etienne Pallier | |
104 | 68 | Etienne Pallier | <pre> |
105 | 74 | Etienne Pallier | $ mkdir PYROS |
106 | 68 | Etienne Pallier | </pre> |
107 | 13 | Etienne Pallier | |
108 | 13 | Etienne Pallier | --- |
109 | 59 | Etienne Pallier | |
110 | 59 | Etienne Pallier | h3. Get the project (from git) |
111 | 59 | Etienne Pallier | |
112 | 78 | Etienne Pallier | <pre> |
113 | 59 | Etienne Pallier | TODO: |
114 | 79 | Etienne Pallier | |
115 | 80 | Etienne Pallier | $ git ... |
116 | 78 | Etienne Pallier | </pre> |
117 | 78 | Etienne Pallier | |
118 | 59 | Etienne Pallier | |
119 | 59 | Etienne Pallier | |
120 | 59 | Etienne Pallier | --- |
121 | 59 | Etienne Pallier | |
122 | 60 | Etienne Pallier | h3. Create virtualenv with python3.5 dedicated to pyros project (inside the project folder) |
123 | 3 | Etienne Pallier | |
124 | 75 | Etienne Pallier | $ cd PYROS/ |
125 | 3 | Etienne Pallier | |
126 | 3 | Etienne Pallier | $ which python3.5 |
127 | 3 | Etienne Pallier | /opt/local/bin/python3.5 |
128 | 3 | Etienne Pallier | |
129 | 15 | Etienne Pallier | $ virtualenv-3.5 venv_py35_pyros -p /opt/local/bin/python3.5 |
130 | 3 | Etienne Pallier | => creates a venv_py35_pyros/ folder inside pyros/ |
131 | 3 | Etienne Pallier | |
132 | 1 | Etienne Pallier | |
133 | 1 | Etienne Pallier | |
134 | 7 | Etienne Pallier | --- |
135 | 3 | Etienne Pallier | |
136 | 65 | Etienne Pallier | h3. Activate the python virtual environment (from inside the project) |
137 | 7 | Etienne Pallier | |
138 | 55 | Etienne Pallier | <pre> |
139 | 1 | Etienne Pallier | |
140 | 65 | Etienne Pallier | $ pwd |
141 | 76 | Etienne Pallier | .../PYROS |
142 | 1 | Etienne Pallier | |
143 | 65 | Etienne Pallier | $ source ./venv_py35_pyros/bin/activate |
144 | 65 | Etienne Pallier | |
145 | 3 | Etienne Pallier | $ python -V |
146 | 1 | Etienne Pallier | Python 3.5.1 |
147 | 3 | Etienne Pallier | |
148 | 3 | Etienne Pallier | $ which pip |
149 | 77 | Etienne Pallier | .../PYROS/venv_py35_pyros/bin/pip |
150 | 16 | Etienne Pallier | |
151 | 18 | Etienne Pallier | Upgrade pip to last version available : |
152 | 3 | Etienne Pallier | $ pip install --upgrade pip |
153 | 3 | Etienne Pallier | Collecting pip |
154 | 3 | Etienne Pallier | Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB) |
155 | 3 | Etienne Pallier | Installing collected packages: pip |
156 | 3 | Etienne Pallier | Found existing installation: pip 7.1.2 |
157 | 3 | Etienne Pallier | Uninstalling pip-7.1.2: |
158 | 3 | Etienne Pallier | Successfully uninstalled pip-7.1.2 |
159 | 1 | Etienne Pallier | Successfully installed pip-8.1.1 |
160 | 55 | Etienne Pallier | |
161 | 55 | Etienne Pallier | </pre> |
162 | 18 | Etienne Pallier | |
163 | 27 | Etienne Pallier | h3. Install 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 | 71 | Etienne Pallier | YES !!! |
280 | 21 | Etienne Pallier | |
281 | 1 | Etienne Pallier | </pre> |
282 | 1 | Etienne Pallier | |
283 | 12 | Etienne Pallier | |
284 | 12 | Etienne Pallier | |
285 | 82 | Etienne Pallier | * *Set Requirements* |
286 | 82 | Etienne Pallier | |
287 | 82 | Etienne Pallier | <pre> |
288 | 82 | Etienne Pallier | $ pip freeze > REQUIREMENTS.txt |
289 | 82 | Etienne Pallier | </pre> |
290 | 12 | Etienne Pallier | |
291 | 12 | Etienne Pallier | --- |
292 | 28 | Etienne Pallier | |
293 | 12 | Etienne Pallier | h3. Project organization |
294 | 29 | Etienne Pallier | |
295 | 1 | Etienne Pallier | Example of a good organization : |
296 | 29 | Etienne Pallier | |
297 | 29 | Etienne Pallier | 1 project = N applis |
298 | 30 | Etienne Pallier | (but 1 appli can be part of many projects) |
299 | 12 | Etienne Pallier | (then 1 appli = N models) |
300 | 31 | Etienne Pallier | |
301 | 34 | Etienne Pallier | <pre> |
302 | 29 | Etienne Pallier | |
303 | 34 | Etienne Pallier | MYPROJECT/ |
304 | 50 | Etienne Pallier | |
305 | 1 | Etienne Pallier | |
306 | 1 | Etienne Pallier | src/ |
307 | 34 | Etienne Pallier | myproject/ |
308 | 34 | Etienne Pallier | appli1/ |
309 | 12 | Etienne Pallier | appli2/ |
310 | 34 | Etienne Pallier | … |
311 | 34 | Etienne Pallier | appliN/ |
312 | 12 | Etienne Pallier | |
313 | 34 | Etienne Pallier | public/ |
314 | 34 | Etienne Pallier | static/ |
315 | 12 | Etienne Pallier | |
316 | 1 | Etienne Pallier | private/ |
317 | 89 | Etienne Pallier | REQUIREMENTS.txt |
318 | 50 | Etienne Pallier | |
319 | 50 | Etienne Pallier | venv_py35_pyros/ |
320 | 1 | Etienne Pallier | |
321 | 1 | Etienne Pallier | </pre> |
322 | 1 | Etienne Pallier | |
323 | 37 | Etienne Pallier | |
324 | 37 | Etienne Pallier | Set needed folders: |
325 | 37 | Etienne Pallier | <pre> |
326 | 81 | Etienne Pallier | $ cd PYROS/ |
327 | 12 | Etienne Pallier | $ mkdir private public |
328 | 37 | Etienne Pallier | $ mkdir public/static |
329 | 3 | Etienne Pallier | </pre> |
330 | 7 | Etienne Pallier | |
331 | 3 | Etienne Pallier | --- |
332 | 39 | Etienne Pallier | |
333 | 7 | Etienne Pallier | h3. Create Django project pyros |
334 | 38 | Etienne Pallier | |
335 | 38 | Etienne Pallier | <pre> |
336 | 1 | Etienne Pallier | |
337 | 83 | Etienne Pallier | From inside the project: |
338 | 83 | Etienne Pallier | $ pwd |
339 | 83 | Etienne Pallier | .../PYROS/ |
340 | 83 | Etienne Pallier | |
341 | 1 | Etienne Pallier | $ django-admin startproject pyros |
342 | 1 | Etienne Pallier | |
343 | 84 | Etienne Pallier | $ mv pyros src |
344 | 84 | Etienne Pallier | |
345 | 86 | Etienne Pallier | $ mv REQUIREMENTS.txt private/ |
346 | 1 | Etienne Pallier | |
347 | 86 | Etienne Pallier | We have then this architecture: |
348 | 86 | Etienne Pallier | |
349 | 1 | Etienne Pallier | PYROS |
350 | 83 | Etienne Pallier | ├── private |
351 | 86 | Etienne Pallier | │ └── REQUIREMENTS.txt |
352 | 83 | Etienne Pallier | ├── public |
353 | 83 | Etienne Pallier | │ └── static |
354 | 83 | Etienne Pallier | ├── src |
355 | 83 | Etienne Pallier | │ ├── db.sqlite3 |
356 | 83 | Etienne Pallier | │ ├── manage.py |
357 | 1 | Etienne Pallier | │ ├── pyros |
358 | 84 | Etienne Pallier | │ │ ├── __init__.py |
359 | 84 | Etienne Pallier | │ │ ├── settings.py |
360 | 84 | Etienne Pallier | │ │ ├── urls.py |
361 | 84 | Etienne Pallier | │ │ └── wsgi.py |
362 | 85 | Etienne Pallier | └── venv_py35_pyros |
363 | 3 | Etienne Pallier | |
364 | 3 | Etienne Pallier | |
365 | 3 | Etienne Pallier | $ cd src/ |
366 | 40 | 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 | 3 | Etienne Pallier | </pre> |
375 | 7 | Etienne Pallier | |
376 | 3 | Etienne Pallier | |
377 | 42 | Etienne Pallier | --- |
378 | 7 | Etienne Pallier | |
379 | 3 | Etienne Pallier | h3. Set Database engine as MySql |
380 | 3 | Etienne Pallier | |
381 | 41 | Etienne Pallier | Edit src/pyros/settings.py |
382 | 3 | Etienne Pallier | |
383 | 3 | Etienne Pallier | <pre> |
384 | 3 | Etienne Pallier | DATABASES = { |
385 | 1 | Etienne Pallier | 'default': { |
386 | 3 | Etienne Pallier | 'ENGINE': 'django.db.backends.mysql', |
387 | 1 | Etienne Pallier | 'NAME': 'pyros', |
388 | 1 | Etienne Pallier | 'USER': 'root', |
389 | 1 | Etienne Pallier | 'PASSWORD': '' |
390 | 41 | Etienne Pallier | } |
391 | 3 | Etienne Pallier | } |
392 | 7 | Etienne Pallier | </pre> |
393 | 3 | Etienne Pallier | |
394 | 43 | Etienne Pallier | --- |
395 | 7 | Etienne Pallier | |
396 | 43 | Etienne Pallier | h3. Import database into Django (with inspectdb) |
397 | 3 | Etienne Pallier | |
398 | 96 | Etienne Pallier | From the PYROS folder: |
399 | 94 | Etienne Pallier | |
400 | 96 | Etienne Pallier | <pre> |
401 | 95 | Etienne Pallier | $ cd src/ |
402 | 3 | Etienne Pallier | |
403 | 44 | Etienne Pallier | $ ./manage.py inspectdb > models.py |
404 | 94 | Etienne Pallier | </pre> |
405 | 44 | Etienne Pallier | |
406 | 97 | Etienne Pallier | Issue on Mac OS X: |
407 | 3 | Etienne Pallier | <pre> |
408 | 3 | Etienne Pallier | Traceback (most recent call last): |
409 | 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> |
410 | 3 | Etienne Pallier | import MySQLdb as Database |
411 | 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> |
412 | 3 | Etienne Pallier | import _mysql |
413 | 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 |
414 | 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 |
415 | 3 | Etienne Pallier | Reason: image not found |
416 | 3 | Etienne Pallier | |
417 | 3 | Etienne Pallier | => BOUH !!! |
418 | 3 | Etienne Pallier | |
419 | 3 | Etienne Pallier | LA SOLUTION EST ICI : http://stackoverflow.com/questions/6383310/python-mysqldb-library-not-loaded-libmysqlclient-18-dylib |
420 | 3 | Etienne Pallier | |
421 | 3 | Etienne Pallier | ( |
422 | 3 | Etienne Pallier | Apparemment, ceci aurait dû suffire: |
423 | 3 | Etienne Pallier | mkdir -p /usr/local/lib |
424 | 3 | Etienne Pallier | ln -s /usr/local/mysql/lib/libmysql* /usr/local/lib |
425 | 3 | Etienne Pallier | ) |
426 | 3 | Etienne Pallier | |
427 | 3 | Etienne Pallier | Mais j’ai fait ceci: |
428 | 3 | Etienne Pallier | |
429 | 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 |
430 | 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: |
431 | 3 | Etienne Pallier | libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0) |
432 | 3 | Etienne Pallier | ... |
433 | 3 | Etienne Pallier | |
434 | 1 | Etienne Pallier | $ locate libmysqlclient.18.dylib |
435 | 1 | Etienne Pallier | /Applications/XAMPP/xamppfiles/lib/libmysqlclient.18.dylib |
436 | 1 | Etienne Pallier | /Library/SystemMigration/History/Migration-68137DFB-CB6A-4FBB-81E2-11BDB5D01E48/QuarantineRoot/usr/lib/libmysqlclient.18.dylib |
437 | 1 | Etienne Pallier | |
438 | 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 |
439 | 10 | Etienne Pallier | |
440 | 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 |
441 | 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: |
442 | 3 | Etienne Pallier | /Applications/XAMPP/xamppfiles/lib/libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0) |
443 | 1 | Etienne Pallier | ... |
444 | 1 | Etienne Pallier | |
445 | 3 | Etienne Pallier | $ ./manage.py inspectdb > models.py |
446 | 44 | Etienne Pallier | |
447 | 3 | Etienne Pallier | => YES !!! |
448 | 3 | Etienne Pallier | </pre> |
449 | 7 | Etienne Pallier | |
450 | 3 | Etienne Pallier | |
451 | 48 | Etienne Pallier | --- |
452 | 7 | Etienne Pallier | |
453 | 3 | Etienne Pallier | h3. Create a Django application pyrosapp |
454 | 3 | Etienne Pallier | |
455 | 3 | Etienne Pallier | $ ./manage.py startapp pyrosapp |
456 | 67 | Etienne Pallier | |
457 | 3 | Etienne Pallier | $ tree src |
458 | 3 | Etienne Pallier | <pre> |
459 | 3 | Etienne Pallier | src |
460 | 3 | Etienne Pallier | ├── manage.py |
461 | 3 | Etienne Pallier | ├── pyros |
462 | 3 | Etienne Pallier | │ ├── __init__.py |
463 | 3 | Etienne Pallier | │ ├── __pycache__ |
464 | 3 | Etienne Pallier | │ │ ├── __init__.cpython-35.pyc |
465 | 3 | Etienne Pallier | │ │ ├── settings.cpython-35.pyc |
466 | 3 | Etienne Pallier | │ │ ├── urls.cpython-35.pyc |
467 | 3 | Etienne Pallier | │ │ └── wsgi.cpython-35.pyc |
468 | 3 | Etienne Pallier | │ ├── settings.py |
469 | 3 | Etienne Pallier | │ ├── urls.py |
470 | 3 | Etienne Pallier | │ └── wsgi.py |
471 | 1 | Etienne Pallier | └── pyrosapp |
472 | 3 | Etienne Pallier | ├── __init__.py |
473 | 1 | Etienne Pallier | ├── admin.py |
474 | 1 | Etienne Pallier | ├── apps.py |
475 | 3 | Etienne Pallier | ├── migrations |
476 | 3 | Etienne Pallier | │ └── __init__.py |
477 | 1 | Etienne Pallier | ├── models.py |
478 | 67 | Etienne Pallier | ├── tests.py |
479 | 1 | Etienne Pallier | └── views.py |
480 | 7 | Etienne Pallier | </pre> |
481 | 1 | Etienne Pallier | |
482 | 7 | Etienne Pallier | --- |
483 | 7 | Etienne Pallier | |
484 | 3 | Etienne Pallier | h3. Replace the default pyrosapp models.py with the inspectdb generated one |
485 | 3 | Etienne Pallier | |
486 | 3 | Etienne Pallier | $ mv models.py pyrosapp/ |
487 | 3 | Etienne Pallier | |
488 | 3 | Etienne Pallier | |
489 | 7 | Etienne Pallier | |
490 | 1 | Etienne Pallier | |
491 | 9 | Etienne Pallier | |
492 | 47 | Etienne Pallier | --- |
493 | 3 | Etienne Pallier | |
494 | 3 | Etienne Pallier | h3. *TODO: Fix and improve the inspectdb generated file models.py* |
495 | 3 | Etienne Pallier | |
496 | 8 | Etienne Pallier | $ cd pyrosapp/ |
497 | 1 | Etienne Pallier | |
498 | 1 | Etienne Pallier | $ vi models.py |