Wiki
Version 3 (Etienne Pallier, 03/17/2016 06:41 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 | 3 | Etienne Pallier | h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}INSTALLATION% |
13 | 2 | Etienne Pallier | |
14 | 2 | Etienne Pallier | |
15 | 1 | Etienne Pallier | |
16 | 3 | Etienne Pallier | 0) Create database |
17 | 1 | Etienne Pallier | |
18 | 3 | Etienne Pallier | One liner: |
19 | 3 | Etienne Pallier | $ mysql -u root < pyros.sql |
20 | 1 | Etienne Pallier | |
21 | 3 | Etienne Pallier | Or : |
22 | 3 | Etienne Pallier | $ mysql -u root |
23 | 3 | Etienne Pallier | mysql> create database pyros; |
24 | 3 | Etienne Pallier | mysql> use pyros; |
25 | 3 | Etienne Pallier | mysql> source pyros.sql; |
26 | 1 | Etienne Pallier | |
27 | 3 | Etienne Pallier | ( |
28 | 3 | Etienne Pallier | TODO: |
29 | 3 | Etienne Pallier | mysql> grant all on pyros.* to pyros@localhost identified by ‘pyros’;) |
30 | 3 | Etienne Pallier | mysql> flush privileges; |
31 | 3 | Etienne Pallier | ) |
32 | 1 | Etienne Pallier | |
33 | 1 | Etienne Pallier | |
34 | 1 | Etienne Pallier | |
35 | 3 | Etienne Pallier | 1) install python3.5 |
36 | 1 | Etienne Pallier | |
37 | 3 | Etienne Pallier | $ sudo port install python35 |
38 | 1 | Etienne Pallier | |
39 | 1 | Etienne Pallier | |
40 | 1 | Etienne Pallier | |
41 | 3 | Etienne Pallier | 2) create project dir |
42 | 3 | Etienne Pallier | |
43 | 3 | Etienne Pallier | $ mkdir pyros |
44 | 3 | Etienne Pallier | |
45 | 3 | Etienne Pallier | |
46 | 1 | Etienne Pallier | |
47 | 3 | Etienne Pallier | Exemple de bonne organisation : |
48 | 1 | Etienne Pallier | |
49 | 3 | Etienne Pallier | 1 projet = N applis |
50 | 3 | Etienne Pallier | (mais 1 appli peut faire partie de plusieurs projets) |
51 | 1 | Etienne Pallier | |
52 | 3 | Etienne Pallier | MONPROJET/ |
53 | 3 | Etienne Pallier | src/ |
54 | 3 | Etienne Pallier | monprojet/ |
55 | 3 | Etienne Pallier | appli1 |
56 | 3 | Etienne Pallier | appli2 |
57 | 3 | Etienne Pallier | … |
58 | 3 | Etienne Pallier | appliN |
59 | 3 | Etienne Pallier | public/ |
60 | 3 | Etienne Pallier | private/ |
61 | 3 | Etienne Pallier | requirements.txt |
62 | 1 | Etienne Pallier | |
63 | 1 | Etienne Pallier | |
64 | 1 | Etienne Pallier | |
65 | 3 | Etienne Pallier | 3) Set needed folders (inside pyros/) |
66 | 1 | Etienne Pallier | |
67 | 3 | Etienne Pallier | $ mkdir private public |
68 | 3 | Etienne Pallier | $ mkdir public/static |
69 | 1 | Etienne Pallier | |
70 | 1 | Etienne Pallier | |
71 | 1 | Etienne Pallier | |
72 | 3 | Etienne Pallier | 4) create virtualenv with python3.4 dedicated to pyros project |
73 | 3 | Etienne Pallier | |
74 | 3 | Etienne Pallier | $ cd pyros/ |
75 | 3 | Etienne Pallier | |
76 | 3 | Etienne Pallier | $ which python3.5 |
77 | 3 | Etienne Pallier | /opt/local/bin/python3.5 |
78 | 3 | Etienne Pallier | |
79 | 3 | Etienne Pallier | $ virtualenv-3.4 venv_py35_pyros -p /opt/local/bin/python3.5 |
80 | 3 | Etienne Pallier | => creates a venv_py35_pyros/ folder inside pyros/ |
81 | 3 | Etienne Pallier | |
82 | 3 | Etienne Pallier | |
83 | 3 | Etienne Pallier | |
84 | 3 | Etienne Pallier | 5) Activate venv and install needed python packages |
85 | 3 | Etienne Pallier | |
86 | 3 | Etienne Pallier | $ source venv_py35_pyros/bin/activate |
87 | 3 | Etienne Pallier | |
88 | 3 | Etienne Pallier | $ python -V |
89 | 3 | Etienne Pallier | Python 3.5.1 |
90 | 3 | Etienne Pallier | |
91 | 3 | Etienne Pallier | $ which pip |
92 | 3 | Etienne Pallier | …/pyros/venv_py35_pyros/bin/pip |
93 | 3 | Etienne Pallier | |
94 | 3 | Etienne Pallier | $ pip install --upgrade pip |
95 | 3 | Etienne Pallier | Collecting pip |
96 | 3 | Etienne Pallier | Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB) |
97 | 3 | Etienne Pallier | Installing collected packages: pip |
98 | 3 | Etienne Pallier | Found existing installation: pip 7.1.2 |
99 | 3 | Etienne Pallier | Uninstalling pip-7.1.2: |
100 | 3 | Etienne Pallier | Successfully uninstalled pip-7.1.2 |
101 | 3 | Etienne Pallier | Successfully installed pip-8.1.1 |
102 | 3 | Etienne Pallier | |
103 | 3 | Etienne Pallier | $ pip install django |
104 | 3 | Etienne Pallier | Collecting django |
105 | 3 | Etienne Pallier | Downloading Django-1.9.4-py2.py3-none-any.whl (6.6MB) |
106 | 3 | Etienne Pallier | Installing collected packages: django |
107 | 3 | Etienne Pallier | Successfully installed django-1.9.4 |
108 | 3 | Etienne Pallier | |
109 | 3 | Etienne Pallier | $ pip install --upgrade django |
110 | 3 | Etienne Pallier | Requirement already up-to-date: django in ./venv_py35_pyros/lib/python3.5/site-packages |
111 | 3 | Etienne Pallier | |
112 | 3 | Etienne Pallier | $ pip install django-admin-tools |
113 | 3 | Etienne Pallier | Collecting django-admin-tools |
114 | 3 | Etienne Pallier | Downloading django_admin_tools-0.7.2-py2.py3-none-any.whl (289kB) |
115 | 3 | Etienne Pallier | Installing collected packages: django-admin-tools |
116 | 3 | Etienne Pallier | Successfully installed django-admin-tools-0.7.2 |
117 | 3 | Etienne Pallier | |
118 | 3 | Etienne Pallier | $ pip install gunicorn |
119 | 3 | Etienne Pallier | Collecting gunicorn |
120 | 3 | Etienne Pallier | Downloading gunicorn-19.4.5-py2.py3-none-any.whl (112kB) |
121 | 3 | Etienne Pallier | Installing collected packages: gunicorn |
122 | 3 | Etienne Pallier | Successfully installed gunicorn-19.4.5 |
123 | 3 | Etienne Pallier | |
124 | 3 | Etienne Pallier | $ pip install mysqlclient |
125 | 3 | Etienne Pallier | Collecting mysqlclient |
126 | 3 | Etienne Pallier | Downloading mysqlclient-1.3.7.tar.gz (79kB) |
127 | 3 | Etienne Pallier | Building wheels for collected packages: mysqlclient |
128 | 3 | Etienne Pallier | Running setup.py bdist_wheel for mysqlclient ... error |
129 | 3 | Etienne Pallier | … |
130 | 3 | Etienne Pallier | ---------------------------------------- |
131 | 3 | Etienne Pallier | Failed building wheel for mysqlclient |
132 | 3 | Etienne Pallier | Running setup.py clean for mysqlclient |
133 | 3 | Etienne Pallier | Failed to build mysqlclient |
134 | 3 | Etienne Pallier | Installing collected packages: mysqlclient |
135 | 3 | Etienne Pallier | Running setup.py install for mysqlclient ... done |
136 | 3 | Etienne Pallier | Successfully installed mysqlclient-1.3.7 |
137 | 3 | Etienne Pallier | |
138 | 3 | Etienne Pallier | BOUH !!! |
139 | 3 | Etienne Pallier | |
140 | 3 | Etienne Pallier | $ pip install --upgrade wheel |
141 | 3 | Etienne Pallier | Collecting wheel |
142 | 3 | Etienne Pallier | Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB) |
143 | 3 | Etienne Pallier | Installing collected packages: wheel |
144 | 3 | Etienne Pallier | Found existing installation: wheel 0.24.0 |
145 | 3 | Etienne Pallier | Uninstalling wheel-0.24.0: |
146 | 3 | Etienne Pallier | Successfully uninstalled wheel-0.24.0 |
147 | 3 | Etienne Pallier | Successfully installed wheel-0.29.0 |
148 | 3 | Etienne Pallier | |
149 | 3 | Etienne Pallier | $ pip uninstall mysqlclient |
150 | 3 | Etienne Pallier | |
151 | 3 | Etienne Pallier | $ pip install mysqlclient |
152 | 3 | Etienne Pallier | Collecting mysqlclient |
153 | 3 | Etienne Pallier | Using cached mysqlclient-1.3.7.tar.gz |
154 | 3 | Etienne Pallier | Building wheels for collected packages: mysqlclient |
155 | 3 | Etienne Pallier | Running setup.py bdist_wheel for mysqlclient ... done |
156 | 3 | Etienne Pallier | Stored in directory: /Users/epallier/Library/Caches/pip/wheels/9b/06/50/d11418c26cf8f2156b13d4363b5afde8e7e75ebb8540d0228d |
157 | 3 | Etienne Pallier | Successfully built mysqlclient |
158 | 3 | Etienne Pallier | Installing collected packages: mysqlclient |
159 | 3 | Etienne Pallier | Successfully installed mysqlclient-1.3.7 |
160 | 3 | Etienne Pallier | |
161 | 3 | Etienne Pallier | YES !!! |
162 | 3 | Etienne Pallier | |
163 | 3 | Etienne Pallier | |
164 | 3 | Etienne Pallier | |
165 | 3 | Etienne Pallier | $ pip install django-debug-toolbar |
166 | 3 | Etienne Pallier | Collecting django-debug-toolbar |
167 | 3 | Etienne Pallier | Downloading django_debug_toolbar-1.4-py2.py3-none-any.whl (212kB) |
168 | 3 | 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) |
169 | 3 | Etienne Pallier | Collecting sqlparse (from django-debug-toolbar) |
170 | 3 | Etienne Pallier | Downloading sqlparse-0.1.19.tar.gz (58kB) |
171 | 3 | Etienne Pallier | Building wheels for collected packages: sqlparse |
172 | 3 | Etienne Pallier | Running setup.py bdist_wheel for sqlparse ... done |
173 | 3 | Etienne Pallier | Stored in directory: /Users/epallier/Library/Caches/pip/wheels/7b/d4/72/6011bb100dd5fc213164e4bbee13d4e03261dd54ce6a5de6b8 |
174 | 3 | Etienne Pallier | Successfully built sqlparse |
175 | 3 | Etienne Pallier | Installing collected packages: sqlparse, django-debug-toolbar |
176 | 3 | Etienne Pallier | Successfully installed django-debug-toolbar-1.4 sqlparse-0.1.19 |
177 | 3 | Etienne Pallier | |
178 | 3 | Etienne Pallier | $ pip install django-extensions |
179 | 3 | Etienne Pallier | Collecting django-extensions |
180 | 3 | Etienne Pallier | Downloading django_extensions-1.6.1-py2.py3-none-any.whl (202kB) |
181 | 3 | Etienne Pallier | Collecting six>=1.2 (from django-extensions) |
182 | 3 | Etienne Pallier | Downloading six-1.10.0-py2.py3-none-any.whl |
183 | 3 | Etienne Pallier | Installing collected packages: six, django-extensions |
184 | 3 | Etienne Pallier | Successfully installed django-extensions-1.6.1 six-1.10.0 |
185 | 3 | Etienne Pallier | |
186 | 3 | Etienne Pallier | $ pip install django-suit |
187 | 3 | Etienne Pallier | Collecting django-suit |
188 | 3 | Etienne Pallier | Downloading django-suit-0.2.18.tar.gz (587kB) |
189 | 3 | Etienne Pallier | Building wheels for collected packages: django-suit |
190 | 3 | Etienne Pallier | Running setup.py bdist_wheel for django-suit ... done |
191 | 3 | Etienne Pallier | Stored in directory: /Users/epallier/Library/Caches/pip/wheels/12/8b/9a/e02ab0ad9229881638aa040d47d77c8f562999533811927d41 |
192 | 3 | Etienne Pallier | Successfully built django-suit |
193 | 3 | Etienne Pallier | Installing collected packages: django-suit |
194 | 3 | Etienne Pallier | Successfully installed django-suit-0.2.18 |
195 | 3 | Etienne Pallier | |
196 | 3 | Etienne Pallier | |
197 | 3 | Etienne Pallier | |
198 | 3 | Etienne Pallier | 6) Create django project pyros |
199 | 3 | Etienne Pallier | |
200 | 3 | Etienne Pallier | $ django-admin startproject pyros |
201 | 3 | Etienne Pallier | |
202 | 3 | Etienne Pallier | $ tree pyros/ |
203 | 3 | Etienne Pallier | pyros/ |
204 | 3 | Etienne Pallier | ├── manage.py |
205 | 3 | Etienne Pallier | └── pyros |
206 | 3 | Etienne Pallier | ├── __init__.py |
207 | 3 | Etienne Pallier | ├── settings.py |
208 | 3 | Etienne Pallier | ├── urls.py |
209 | 3 | Etienne Pallier | └── wsgi.py |
210 | 3 | Etienne Pallier | |
211 | 3 | Etienne Pallier | |
212 | 3 | Etienne Pallier | $ mv pyros src |
213 | 3 | Etienne Pallier | |
214 | 3 | Etienne Pallier | $ cd src/ |
215 | 3 | Etienne Pallier | |
216 | 3 | Etienne Pallier | $ ./manage.py runserver |
217 | 3 | Etienne Pallier | (ou gunicorn pyros.wsgi) |
218 | 3 | Etienne Pallier | ==> http://localhost:8000 |
219 | 3 | Etienne Pallier | |
220 | 3 | Etienne Pallier | |
221 | 3 | Etienne Pallier | |
222 | 3 | Etienne Pallier | 8) Set Database mysql |
223 | 3 | Etienne Pallier | |
224 | 3 | Etienne Pallier | Edit src/pyros/settings.py |
225 | 3 | Etienne Pallier | |
226 | 3 | Etienne Pallier | DATABASES = { |
227 | 3 | Etienne Pallier | 'default': { |
228 | 3 | Etienne Pallier | 'ENGINE': 'django.db.backends.mysql', |
229 | 3 | Etienne Pallier | 'NAME': 'pyros', |
230 | 3 | Etienne Pallier | 'USER': 'root', |
231 | 3 | Etienne Pallier | 'PASSWORD': '' |
232 | 3 | Etienne Pallier | } |
233 | 3 | Etienne Pallier | } |
234 | 3 | Etienne Pallier | |
235 | 3 | Etienne Pallier | |
236 | 3 | Etienne Pallier | 9) Import database into django |
237 | 3 | Etienne Pallier | |
238 | 3 | Etienne Pallier | cd src/ |
239 | 3 | Etienne Pallier | |
240 | 3 | Etienne Pallier | $ ./manage.py inspectdb > models.py |
241 | 3 | Etienne Pallier | |
242 | 3 | Etienne Pallier | Traceback (most recent call last): |
243 | 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> |
244 | 3 | Etienne Pallier | import MySQLdb as Database |
245 | 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> |
246 | 3 | Etienne Pallier | import _mysql |
247 | 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 |
248 | 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 |
249 | 3 | Etienne Pallier | Reason: image not found |
250 | 3 | Etienne Pallier | |
251 | 3 | Etienne Pallier | => BOUH !!! |
252 | 3 | Etienne Pallier | |
253 | 3 | Etienne Pallier | LA SOLUTION EST ICI : http://stackoverflow.com/questions/6383310/python-mysqldb-library-not-loaded-libmysqlclient-18-dylib |
254 | 3 | Etienne Pallier | |
255 | 3 | Etienne Pallier | ( |
256 | 3 | Etienne Pallier | Apparemment, ceci aurait dû suffire: |
257 | 3 | Etienne Pallier | mkdir -p /usr/local/lib |
258 | 3 | Etienne Pallier | ln -s /usr/local/mysql/lib/libmysql* /usr/local/lib |
259 | 3 | Etienne Pallier | ) |
260 | 3 | Etienne Pallier | |
261 | 3 | Etienne Pallier | |
262 | 3 | Etienne Pallier | Mais j’ai fait ceci: |
263 | 3 | Etienne Pallier | |
264 | 3 | Etienne Pallier | |
265 | 3 | 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 |
266 | 3 | 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: |
267 | 3 | Etienne Pallier | libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0) |
268 | 3 | Etienne Pallier | /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1) |
269 | 3 | Etienne Pallier | /opt/local/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0) |
270 | 3 | Etienne Pallier | /opt/local/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0) |
271 | 3 | Etienne Pallier | |
272 | 3 | Etienne Pallier | $ locate libmysqlclient.18.dylib |
273 | 3 | Etienne Pallier | /Applications/XAMPP/xamppfiles/lib/libmysqlclient.18.dylib |
274 | 3 | Etienne Pallier | /Library/SystemMigration/History/Migration-68137DFB-CB6A-4FBB-81E2-11BDB5D01E48/QuarantineRoot/usr/lib/libmysqlclient.18.dylib |
275 | 3 | Etienne Pallier | |
276 | 3 | 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 |
277 | 3 | Etienne Pallier | |
278 | 3 | Etienne Pallier | |
279 | 3 | Etienne Pallier | $ ./manage.py inspectdb > models.py |
280 | 3 | Etienne Pallier | |
281 | 3 | Etienne Pallier | => YES !!! |
282 | 3 | Etienne Pallier | |
283 | 3 | Etienne Pallier | |
284 | 3 | Etienne Pallier | |
285 | 3 | Etienne Pallier | 10) Create a django application pyrosapp |
286 | 3 | Etienne Pallier | |
287 | 3 | Etienne Pallier | $ ./manage.py startapp pyrosapp |
288 | 3 | Etienne Pallier | |
289 | 3 | Etienne Pallier | $ tree src |
290 | 3 | Etienne Pallier | src |
291 | 3 | Etienne Pallier | ├── db.sqlite3 |
292 | 3 | Etienne Pallier | ├── manage.py |
293 | 3 | Etienne Pallier | ├── pyros |
294 | 3 | Etienne Pallier | │ ├── __init__.py |
295 | 3 | Etienne Pallier | │ ├── __pycache__ |
296 | 3 | Etienne Pallier | │ │ ├── __init__.cpython-35.pyc |
297 | 3 | Etienne Pallier | │ │ ├── settings.cpython-35.pyc |
298 | 3 | Etienne Pallier | │ │ ├── urls.cpython-35.pyc |
299 | 3 | Etienne Pallier | │ │ └── wsgi.cpython-35.pyc |
300 | 3 | Etienne Pallier | │ ├── settings.py |
301 | 3 | Etienne Pallier | │ ├── urls.py |
302 | 3 | Etienne Pallier | │ └── wsgi.py |
303 | 3 | Etienne Pallier | └── pyrosapp |
304 | 3 | Etienne Pallier | ├── __init__.py |
305 | 3 | Etienne Pallier | ├── admin.py |
306 | 3 | Etienne Pallier | ├── apps.py |
307 | 3 | Etienne Pallier | ├── migrations |
308 | 3 | Etienne Pallier | │ └── __init__.py |
309 | 3 | Etienne Pallier | ├── models.py |
310 | 3 | Etienne Pallier | ├── tests.py |
311 | 3 | Etienne Pallier | └── views.py |
312 | 3 | Etienne Pallier | |
313 | 3 | Etienne Pallier | |
314 | 3 | Etienne Pallier | 11) Replace the default pyrosapp models.py with the inspectdb generated one |
315 | 3 | Etienne Pallier | |
316 | 3 | Etienne Pallier | $ mv models.py pyrosapp/ |
317 | 3 | Etienne Pallier | |
318 | 3 | Etienne Pallier | |
319 | 3 | Etienne Pallier | TODO : |
320 | 3 | Etienne Pallier | |
321 | 3 | Etienne Pallier | |
322 | 3 | Etienne Pallier | 12) Fix and improve the inspectdb generated file models.py |
323 | 3 | Etienne Pallier | |
324 | 3 | Etienne Pallier | $ cd pyrosapp/ |
325 | 3 | Etienne Pallier | |
326 | 3 | Etienne Pallier | $ vi models.py |