Wiki
Version 263 (Etienne Pallier, 03/23/2016 08:22 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 | 251 | Etienne Pallier | * Intégration dans Eclipse |
14 | 125 | Etienne Pallier | |
15 | 251 | Etienne Pallier | * Séparation des BD Django et Pyros |
16 | 126 | Etienne Pallier | |
17 | 174 | Etienne Pallier | * Intégration des modules Django déjà développés |
18 | 125 | Etienne Pallier | |
19 | 121 | Etienne Pallier | |
20 | 3 | Etienne Pallier | --- |
21 | 1 | Etienne Pallier | |
22 | 140 | Etienne Pallier | h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}I - DATABASE SCHEMA (v0.2.1)% |
23 | 116 | Etienne Pallier | |
24 | 116 | Etienne Pallier | |
25 | 117 | Etienne Pallier | {{thumbnail(PYROS_PDM_v021.png, size=300, title=Pyros data model)}} |
26 | 121 | Etienne Pallier | |
27 | 121 | Etienne Pallier | |
28 | 121 | Etienne Pallier | --- |
29 | 116 | Etienne Pallier | |
30 | 141 | Etienne Pallier | h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}II - Get the project (from gitlab)% |
31 | 141 | Etienne Pallier | |
32 | 253 | Etienne Pallier | h3. Project structure |
33 | 1 | Etienne Pallier | |
34 | 253 | Etienne Pallier | Once you have fetched the project, you should obtain this structure: |
35 | 1 | Etienne Pallier | |
36 | 226 | Etienne Pallier | <pre> |
37 | 1 | Etienne Pallier | |
38 | 1 | Etienne Pallier | PYROS/ |
39 | 254 | Etienne Pallier | ├── install/ |
40 | 254 | Etienne Pallier | │ └── REQUIREMENTS.txt |
41 | 254 | Etienne Pallier | │ └── INSTALLATION.txt |
42 | 226 | Etienne Pallier | ├── public/ |
43 | 226 | Etienne Pallier | │ └── static/ |
44 | 226 | Etienne Pallier | ├── src/ |
45 | 226 | Etienne Pallier | │ ├── manage.py |
46 | 226 | Etienne Pallier | │ ├── pyros/ |
47 | 226 | Etienne Pallier | │ │ ├── __init__.py |
48 | 226 | Etienne Pallier | │ │ ├── __pycache__ |
49 | 226 | Etienne Pallier | │ │ ├── settings.py |
50 | 1 | Etienne Pallier | │ │ ├── urls.py |
51 | 1 | Etienne Pallier | │ │ └── wsgi.py |
52 | 1 | Etienne Pallier | │ └── pyrosapp/ |
53 | 1 | Etienne Pallier | │ ├── __init__.py |
54 | 1 | Etienne Pallier | │ ├── admin.py |
55 | 1 | Etienne Pallier | │ ├── apps.py |
56 | 1 | Etienne Pallier | │ ├── migrations |
57 | 1 | Etienne Pallier | │ ├── models.py |
58 | 1 | Etienne Pallier | │ ├── tests.py |
59 | 1 | Etienne Pallier | │ └── views.py |
60 | 1 | Etienne Pallier | |
61 | 1 | Etienne Pallier | |
62 | 253 | Etienne Pallier | </pre> |
63 | 253 | Etienne Pallier | |
64 | 253 | Etienne Pallier | h3. Get the project from the terminal |
65 | 253 | Etienne Pallier | |
66 | 253 | Etienne Pallier | <pre> |
67 | 253 | Etienne Pallier | git clone https://gitlab.irap.omp.eu/epallier/pyros.git PYROS |
68 | 256 | Etienne Pallier | (or also : git clone git@gitlab.irap.omp.eu:epallier/pyros.git PYROS) |
69 | 253 | Etienne Pallier | </pre> |
70 | 255 | Etienne Pallier | |
71 | 253 | Etienne Pallier | This creates a PYROS/ folder containing the project (with a .git/ subfolder for synchronization with the git repository) |
72 | 253 | Etienne Pallier | |
73 | 257 | Etienne Pallier | _If you just wanted a static copy of the project (without synchronization), just remove the .git/ folder:_ |
74 | 253 | Etienne Pallier | <pre> |
75 | 253 | Etienne Pallier | $ rm -r .git/ |
76 | 253 | Etienne Pallier | </pre> |
77 | 226 | Etienne Pallier | |
78 | 1 | Etienne Pallier | h3. Get the project from Eclipse |
79 | 1 | Etienne Pallier | |
80 | 258 | Etienne Pallier | 1) Fetch the project |
81 | 258 | Etienne Pallier | |
82 | 252 | Etienne Pallier | File/Import project from git |
83 | 1 | Etienne Pallier | |
84 | 258 | Etienne Pallier | Select repository source: Clone URI: https://gitlab.irap.omp.eu/epallier/pyros.git |
85 | 252 | Etienne Pallier | |
86 | 252 | Etienne Pallier | Directory: |
87 | 252 | Etienne Pallier | par défaut, il propose : /Users/epallier/git/pyros |
88 | 258 | Etienne Pallier | mais on peut le mettre ailleurs (c'est ce que j'ai fait) |
89 | 252 | Etienne Pallier | |
90 | 252 | Etienne Pallier | initial branch: master |
91 | 1 | Etienne Pallier | remote name: origin |
92 | 1 | Etienne Pallier | |
93 | 1 | Etienne Pallier | Import as general project |
94 | 252 | Etienne Pallier | |
95 | 252 | Etienne Pallier | Project name: PYROS |
96 | 252 | Etienne Pallier | |
97 | 258 | Etienne Pallier | |
98 | 258 | Etienne Pallier | 2) Configure the project |
99 | 258 | Etienne Pallier | |
100 | 252 | Etienne Pallier | The project is created. Now, you have to set it as a «PyDev » and a « Django » project. |
101 | 252 | Etienne Pallier | |
102 | 252 | Etienne Pallier | clic droit sur le projet / PyDev / set as a PyDev project |
103 | 252 | Etienne Pallier | |
104 | 1 | Etienne Pallier | clic droit sur le projet / PyDev / set as a Django project |
105 | 1 | Etienne Pallier | |
106 | 1 | Etienne Pallier | clic droit sur le projet : on doit maintenant avoir un sous-menu Django |
107 | 252 | Etienne Pallier | |
108 | 252 | Etienne Pallier | clic droit sur le dossier src / PyDev / set as source folder (add to PYTHONPATH) |
109 | 252 | Etienne Pallier | |
110 | 252 | Etienne Pallier | clic droit sur projet / Properties / Pydev-Django : |
111 | 258 | Etienne Pallier | - Django manage.py : src/manage.py |
112 | 258 | Etienne Pallier | - Django settings module : pyros.settings |
113 | 252 | Etienne Pallier | |
114 | 258 | Etienne Pallier | |
115 | 258 | Etienne Pallier | 3) Test by running the web server : |
116 | 252 | Etienne Pallier | clic droit sur projet, Django/Custom command/runserver |
117 | 252 | Etienne Pallier | |
118 | 252 | Etienne Pallier | check http://localhost:8000/ |
119 | 252 | Etienne Pallier | |
120 | 252 | Etienne Pallier | |
121 | 259 | Etienne Pallier | 4) Set Code style |
122 | 252 | Etienne Pallier | |
123 | 252 | Etienne Pallier | Window/Preferences : Pydev / Editor |
124 | 252 | Etienne Pallier | - Auto Imports : uncheck « Do auto import » |
125 | 252 | Etienne Pallier | - Code style: |
126 | 252 | Etienne Pallier | - Locals … : camelCase |
127 | 252 | Etienne Pallier | - Methods : camelCase() with first lower |
128 | 252 | Etienne Pallier | - Code style / Code Formatter: activer « use autopep8.py for code formatting » |
129 | 252 | Etienne Pallier | - Tabs : Tab length : 4 |
130 | 169 | Etienne Pallier | |
131 | 141 | Etienne Pallier | h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}III - INSTALLATION% |
132 | 2 | Etienne Pallier | |
133 | 120 | Etienne Pallier | |
134 | 120 | Etienne Pallier | --- |
135 | 120 | Etienne Pallier | |
136 | 184 | Etienne Pallier | h3. Install MySql (only if necessary) |
137 | 2 | Etienne Pallier | |
138 | 49 | Etienne Pallier | * Linux Ubuntu |
139 | 49 | Etienne Pallier | <pre> |
140 | 107 | Paul Carensac | |
141 | 107 | Paul Carensac | $ sudo apt-get install mysql-server |
142 | 107 | Paul Carensac | $ sudo apt-get install mysql-client |
143 | 107 | Paul Carensac | |
144 | 49 | Etienne Pallier | </pre> |
145 | 49 | Etienne Pallier | |
146 | 49 | Etienne Pallier | * Linux CentOS |
147 | 49 | Etienne Pallier | <pre> |
148 | 49 | Etienne Pallier | TODO: |
149 | 49 | Etienne Pallier | $ sudo yum install mysql |
150 | 49 | Etienne Pallier | ... |
151 | 49 | Etienne Pallier | </pre> |
152 | 49 | Etienne Pallier | |
153 | 49 | Etienne Pallier | * Mac OS X |
154 | 1 | Etienne Pallier | Install XAMPP |
155 | 1 | Etienne Pallier | (but you could also use the pre-installed Mac OS MySql) |
156 | 177 | Etienne Pallier | <pre> |
157 | 177 | Etienne Pallier | TODO: |
158 | 49 | Etienne Pallier | </pre> |
159 | 1 | Etienne Pallier | |
160 | 49 | Etienne Pallier | * Windows |
161 | 243 | Paul Carensac | |
162 | 1 | Etienne Pallier | <pre> |
163 | 243 | Paul Carensac | Download and install the newest version on https://dev.mysql.com/downloads/installer/ |
164 | 243 | Paul Carensac | |
165 | 243 | Paul Carensac | Once installed, launch MySQL Installer. Clic on 'Add...' on the right. |
166 | 243 | Paul Carensac | In MySQLServers section, choose the newest, then clic on next. |
167 | 243 | Paul Carensac | Install and configure the server (just follow the installation guide). |
168 | 243 | Paul Carensac | |
169 | 243 | Paul Carensac | Then launch mysql (via the Windows menu). |
170 | 49 | Etienne Pallier | </pre> |
171 | 49 | Etienne Pallier | |
172 | 49 | Etienne Pallier | |
173 | 49 | Etienne Pallier | --- |
174 | 1 | Etienne Pallier | |
175 | 185 | Etienne Pallier | h3. Install Python3.5 (only if necessary) |
176 | 1 | Etienne Pallier | |
177 | 11 | Etienne Pallier | |
178 | 11 | Etienne Pallier | * Mac OS X : |
179 | 1 | Etienne Pallier | <pre> |
180 | 183 | Etienne Pallier | |
181 | 24 | Etienne Pallier | 1) Installer MacPort |
182 | 24 | Etienne Pallier | (TODO: doc) |
183 | 24 | Etienne Pallier | |
184 | 24 | Etienne Pallier | 2) Installer le "port" python35 |
185 | 1 | Etienne Pallier | $ sudo port install python35 |
186 | 183 | Etienne Pallier | |
187 | 1 | Etienne Pallier | </pre> |
188 | 1 | Etienne Pallier | |
189 | 1 | Etienne Pallier | * Linux (Ubuntu) : |
190 | 1 | Etienne Pallier | <pre> |
191 | 244 | Paul Carensac | $ sudo add-apt-repository ppa:fkrull/deadsnakes |
192 | 244 | Paul Carensac | $ sudo apt-get update |
193 | 244 | Paul Carensac | $ sudo apt-get install python3.5 |
194 | 1 | Etienne Pallier | |
195 | 244 | Paul Carensac | $ sudo pip install virtualenv |
196 | 1 | Etienne Pallier | </pre> |
197 | 1 | Etienne Pallier | |
198 | 244 | Paul Carensac | |
199 | 244 | Paul Carensac | * Windows 7 : |
200 | 244 | Paul Carensac | <pre> |
201 | 244 | Paul Carensac | Go to https://www.python.org/downloads/windows/ , choose the wanted version |
202 | 244 | Paul Carensac | On the wanted version’s page, download Windows x86 executable installer |
203 | 244 | Paul Carensac | |
204 | 244 | Paul Carensac | Run the executable |
205 | 244 | Paul Carensac | * On the first page, check "Add python3.5 to PATH" |
206 | 244 | Paul Carensac | * Choose "Install now" option |
207 | 245 | Paul Carensac | |
208 | 245 | Paul Carensac | Open cmd (windows + R, cmd) : |
209 | 245 | Paul Carensac | $ python -m pip install --upgrade pip |
210 | 245 | Paul Carensac | $ pip install virtualenv |
211 | 244 | Paul Carensac | </pre> |
212 | 1 | Etienne Pallier | |
213 | 183 | Etienne Pallier | * Windows 10 : |
214 | 183 | Etienne Pallier | <pre> |
215 | 187 | Etienne Pallier | TODO: |
216 | 183 | Etienne Pallier | </pre> |
217 | 3 | Etienne Pallier | |
218 | 4 | Etienne Pallier | --- |
219 | 5 | Etienne Pallier | |
220 | 192 | Etienne Pallier | h3. Create a Python3 virtual environment dedicated to the project (inside the project folder) |
221 | 127 | Etienne Pallier | |
222 | 131 | Etienne Pallier | <pre> |
223 | 1 | Etienne Pallier | |
224 | 193 | Etienne Pallier | $ mkdir private/ |
225 | 193 | Etienne Pallier | |
226 | 133 | Etienne Pallier | $ cd private/ |
227 | 3 | Etienne Pallier | |
228 | 246 | Paul Carensac | $ which python3.5 ("where python" for windows) |
229 | 3 | Etienne Pallier | /opt/local/bin/python3.5 |
230 | 15 | Etienne Pallier | |
231 | 127 | Etienne Pallier | $ virtualenv-3.5 venv_py35_pyros -p /opt/local/bin/python3.5 |
232 | 3 | Etienne Pallier | => creates a venv_py35_pyros/ folder inside PYROS/private/ |
233 | 1 | Etienne Pallier | |
234 | 131 | Etienne Pallier | </pre> |
235 | 1 | Etienne Pallier | |
236 | 7 | Etienne Pallier | --- |
237 | 3 | Etienne Pallier | |
238 | 65 | Etienne Pallier | h3. Activate the python virtual environment (from inside the project) |
239 | 7 | Etienne Pallier | |
240 | 55 | Etienne Pallier | <pre> |
241 | 1 | Etienne Pallier | |
242 | 65 | Etienne Pallier | $ pwd |
243 | 134 | Etienne Pallier | .../PYROS/private |
244 | 1 | Etienne Pallier | |
245 | 247 | Paul Carensac | $ source ./venv_py35_pyros/bin/activate (venv_py35_pyros/Scripts/activate on Windows) |
246 | 247 | Paul Carensac | |
247 | 65 | Etienne Pallier | |
248 | 3 | Etienne Pallier | $ python -V |
249 | 1 | Etienne Pallier | Python 3.5.1 |
250 | 3 | Etienne Pallier | |
251 | 3 | Etienne Pallier | $ which pip |
252 | 77 | Etienne Pallier | .../PYROS/venv_py35_pyros/bin/pip |
253 | 16 | Etienne Pallier | |
254 | 194 | Etienne Pallier | Upgrade pip to last version available: |
255 | 3 | Etienne Pallier | $ pip install --upgrade pip |
256 | 3 | Etienne Pallier | Collecting pip |
257 | 3 | Etienne Pallier | Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB) |
258 | 3 | Etienne Pallier | Installing collected packages: pip |
259 | 3 | Etienne Pallier | Found existing installation: pip 7.1.2 |
260 | 3 | Etienne Pallier | Uninstalling pip-7.1.2: |
261 | 3 | Etienne Pallier | Successfully uninstalled pip-7.1.2 |
262 | 1 | Etienne Pallier | Successfully installed pip-8.1.1 |
263 | 194 | Etienne Pallier | |
264 | 194 | Etienne Pallier | Upgrade wheel to last version available: |
265 | 194 | Etienne Pallier | $ pip install --upgrade wheel |
266 | 194 | Etienne Pallier | Collecting wheel |
267 | 194 | Etienne Pallier | Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB) |
268 | 194 | Etienne Pallier | Installing collected packages: wheel |
269 | 194 | Etienne Pallier | Found existing installation: wheel 0.24.0 |
270 | 194 | Etienne Pallier | Uninstalling wheel-0.24.0: |
271 | 194 | Etienne Pallier | Successfully uninstalled wheel-0.24.0 |
272 | 194 | Etienne Pallier | Successfully installed wheel-0.29.0 |
273 | 194 | Etienne Pallier | |
274 | 55 | Etienne Pallier | |
275 | 55 | Etienne Pallier | </pre> |
276 | 18 | Etienne Pallier | |
277 | 212 | Etienne Pallier | h3. Install the needed Python packages (from within the virtual environment) |
278 | 18 | Etienne Pallier | |
279 | 66 | Etienne Pallier | First, be sure that the virtual environment is activated: |
280 | 66 | Etienne Pallier | <pre> |
281 | 66 | Etienne Pallier | $ python -V |
282 | 66 | Etienne Pallier | Python 3.5.1 |
283 | 66 | Etienne Pallier | </pre> |
284 | 66 | Etienne Pallier | |
285 | 62 | Etienne Pallier | * *Automatic Installation of all packages* |
286 | 62 | Etienne Pallier | <pre> |
287 | 90 | Etienne Pallier | $ pip install -r REQUIREMENTS.txt |
288 | 62 | Etienne Pallier | </pre> |
289 | 62 | Etienne Pallier | |
290 | 93 | Etienne Pallier | * *Or, manual installation of each package* |
291 | 62 | Etienne Pallier | |
292 | 62 | Etienne Pallier | * *Install Django* : |
293 | 32 | Etienne Pallier | <pre> |
294 | 3 | Etienne Pallier | $ pip install django |
295 | 3 | Etienne Pallier | Collecting django |
296 | 3 | Etienne Pallier | Downloading Django-1.9.4-py2.py3-none-any.whl (6.6MB) |
297 | 3 | Etienne Pallier | Installing collected packages: django |
298 | 3 | Etienne Pallier | Successfully installed django-1.9.4 |
299 | 3 | Etienne Pallier | |
300 | 3 | Etienne Pallier | $ pip install django-admin-tools |
301 | 3 | Etienne Pallier | Collecting django-admin-tools |
302 | 3 | Etienne Pallier | Downloading django_admin_tools-0.7.2-py2.py3-none-any.whl (289kB) |
303 | 3 | Etienne Pallier | Installing collected packages: django-admin-tools |
304 | 3 | Etienne Pallier | Successfully installed django-admin-tools-0.7.2 |
305 | 3 | Etienne Pallier | |
306 | 21 | Etienne Pallier | $ pip install django-debug-toolbar |
307 | 21 | Etienne Pallier | Collecting django-debug-toolbar |
308 | 21 | Etienne Pallier | Downloading django_debug_toolbar-1.4-py2.py3-none-any.whl (212kB) |
309 | 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) |
310 | 21 | Etienne Pallier | Collecting sqlparse (from django-debug-toolbar) |
311 | 21 | Etienne Pallier | Downloading sqlparse-0.1.19.tar.gz (58kB) |
312 | 21 | Etienne Pallier | Building wheels for collected packages: sqlparse |
313 | 21 | Etienne Pallier | Running setup.py bdist_wheel for sqlparse ... done |
314 | 21 | Etienne Pallier | Stored in directory: /Users/epallier/Library/Caches/pip/wheels/7b/d4/72/6011bb100dd5fc213164e4bbee13d4e03261dd54ce6a5de6b8 |
315 | 21 | Etienne Pallier | Successfully built sqlparse |
316 | 21 | Etienne Pallier | Installing collected packages: sqlparse, django-debug-toolbar |
317 | 21 | Etienne Pallier | Successfully installed django-debug-toolbar-1.4 sqlparse-0.1.19 |
318 | 21 | Etienne Pallier | |
319 | 21 | Etienne Pallier | $ pip install django-extensions |
320 | 21 | Etienne Pallier | Collecting django-extensions |
321 | 21 | Etienne Pallier | Downloading django_extensions-1.6.1-py2.py3-none-any.whl (202kB) |
322 | 21 | Etienne Pallier | Collecting six>=1.2 (from django-extensions) |
323 | 21 | Etienne Pallier | Downloading six-1.10.0-py2.py3-none-any.whl |
324 | 21 | Etienne Pallier | Installing collected packages: six, django-extensions |
325 | 21 | Etienne Pallier | Successfully installed django-extensions-1.6.1 six-1.10.0 |
326 | 21 | Etienne Pallier | |
327 | 21 | Etienne Pallier | $ pip install django-suit |
328 | 21 | Etienne Pallier | Collecting django-suit |
329 | 21 | Etienne Pallier | Downloading django-suit-0.2.18.tar.gz (587kB) |
330 | 21 | Etienne Pallier | Building wheels for collected packages: django-suit |
331 | 1 | Etienne Pallier | Running setup.py bdist_wheel for django-suit ... done |
332 | 1 | Etienne Pallier | Stored in directory: /Users/epallier/Library/Caches/pip/wheels/12/8b/9a/e02ab0ad9229881638aa040d47d77c8f562999533811927d41 |
333 | 1 | Etienne Pallier | Successfully built django-suit |
334 | 1 | Etienne Pallier | Installing collected packages: django-suit |
335 | 1 | Etienne Pallier | Successfully installed django-suit-0.2.18 |
336 | 21 | Etienne Pallier | |
337 | 32 | Etienne Pallier | </pre> |
338 | 32 | Etienne Pallier | |
339 | 63 | Etienne Pallier | * *Install the web application server gunicorn (will be used in production instead of the dev django web server)* : |
340 | 32 | Etienne Pallier | <pre> |
341 | 25 | Etienne Pallier | $ pip install gunicorn |
342 | 25 | Etienne Pallier | Collecting gunicorn |
343 | 25 | Etienne Pallier | Downloading gunicorn-19.4.5-py2.py3-none-any.whl (112kB) |
344 | 21 | Etienne Pallier | Installing collected packages: gunicorn |
345 | 26 | Etienne Pallier | Successfully installed gunicorn-19.4.5 |
346 | 1 | Etienne Pallier | </pre> |
347 | 1 | Etienne Pallier | |
348 | 63 | Etienne Pallier | * *Install the python mysql client*: |
349 | 32 | Etienne Pallier | <pre> |
350 | 32 | Etienne Pallier | $ pip install mysqlclient |
351 | 72 | Etienne Pallier | ... |
352 | 72 | Etienne Pallier | </pre> |
353 | 33 | Etienne Pallier | |
354 | 73 | Etienne Pallier | * => Issue under Mac OS X: |
355 | 72 | Etienne Pallier | <pre> |
356 | 3 | Etienne Pallier | $ pip install mysqlclient |
357 | 3 | Etienne Pallier | Collecting mysqlclient |
358 | 1 | Etienne Pallier | Downloading mysqlclient-1.3.7.tar.gz (79kB) |
359 | 22 | Etienne Pallier | Building wheels for collected packages: mysqlclient |
360 | 3 | Etienne Pallier | Running setup.py bdist_wheel for mysqlclient ... error |
361 | 3 | Etienne Pallier | … |
362 | 1 | Etienne Pallier | ---------------------------------------- |
363 | 1 | Etienne Pallier | Failed building wheel for mysqlclient |
364 | 1 | Etienne Pallier | Running setup.py clean for mysqlclient |
365 | 1 | Etienne Pallier | Failed to build mysqlclient |
366 | 1 | Etienne Pallier | Installing collected packages: mysqlclient |
367 | 1 | Etienne Pallier | Running setup.py install for mysqlclient ... done |
368 | 1 | Etienne Pallier | Successfully installed mysqlclient-1.3.7 |
369 | 1 | Etienne Pallier | |
370 | 1 | Etienne Pallier | BOUH !!! |
371 | 1 | Etienne Pallier | |
372 | 1 | Etienne Pallier | $ pip install --upgrade wheel |
373 | 1 | Etienne Pallier | Collecting wheel |
374 | 1 | Etienne Pallier | Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB) |
375 | 1 | Etienne Pallier | Installing collected packages: wheel |
376 | 1 | Etienne Pallier | Found existing installation: wheel 0.24.0 |
377 | 1 | Etienne Pallier | Uninstalling wheel-0.24.0: |
378 | 1 | Etienne Pallier | Successfully uninstalled wheel-0.24.0 |
379 | 1 | Etienne Pallier | Successfully installed wheel-0.29.0 |
380 | 1 | Etienne Pallier | |
381 | 1 | Etienne Pallier | $ pip uninstall mysqlclient |
382 | 1 | Etienne Pallier | |
383 | 1 | Etienne Pallier | $ pip install mysqlclient |
384 | 1 | Etienne Pallier | Collecting mysqlclient |
385 | 1 | Etienne Pallier | Using cached mysqlclient-1.3.7.tar.gz |
386 | 1 | Etienne Pallier | Building wheels for collected packages: mysqlclient |
387 | 1 | Etienne Pallier | Running setup.py bdist_wheel for mysqlclient ... done |
388 | 1 | Etienne Pallier | Stored in directory: /Users/epallier/Library/Caches/pip/wheels/9b/06/50/d11418c26cf8f2156b13d4363b5afde8e7e75ebb8540d0228d |
389 | 1 | Etienne Pallier | Successfully built mysqlclient |
390 | 1 | Etienne Pallier | Installing collected packages: mysqlclient |
391 | 1 | Etienne Pallier | Successfully installed mysqlclient-1.3.7 |
392 | 1 | Etienne Pallier | |
393 | 1 | Etienne Pallier | YES !!! |
394 | 1 | Etienne Pallier | |
395 | 1 | Etienne Pallier | </pre> |
396 | 1 | Etienne Pallier | |
397 | 107 | Paul Carensac | * => Issues under Ubuntu: |
398 | 107 | Paul Carensac | <pre> |
399 | 107 | Paul Carensac | $ pip install mysqlclient |
400 | 107 | Paul Carensac | Collecting mysqlclient |
401 | 107 | Paul Carensac | Downloading mysqlclient-1.3.7.tar.gz (79kB) |
402 | 107 | Paul Carensac | 100% |████████████████████████████████| 81kB 1.5MB/s |
403 | 107 | Paul Carensac | Complete output from command python setup.py egg_info: |
404 | 107 | Paul Carensac | /bin/sh: 1: mysql_config: not found |
405 | 107 | Paul Carensac | Traceback (most recent call last): |
406 | 107 | Paul Carensac | File "<string>", line 1, in <module> |
407 | 107 | Paul Carensac | [...] |
408 | 107 | Paul Carensac | ---------------------------------------- |
409 | 107 | Paul Carensac | Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-q6j4inuz/mysqlclient/ |
410 | 1 | Etienne Pallier | |
411 | 108 | Paul Carensac | BOUH !!! |
412 | 108 | Paul Carensac | |
413 | 107 | Paul Carensac | $ sudo apt-get install libmysqlclient-dev |
414 | 108 | Paul Carensac | |
415 | 107 | Paul Carensac | $ pip install mysqlclient |
416 | 107 | Paul Carensac | Collecting mysqlclient |
417 | 107 | Paul Carensac | Using cached mysqlclient-1.3.7.tar.gz |
418 | 107 | Paul Carensac | Building wheels for collected packages: mysqlclient |
419 | 107 | Paul Carensac | Running setup.py bdist_wheel for mysqlclient ... error |
420 | 107 | Paul Carensac | … |
421 | 107 | Paul Carensac | _mysql.c:40:20: fatal error: Python.h: No such file or directory |
422 | 107 | Paul Carensac | #include "Python.h" |
423 | 107 | Paul Carensac | ^ |
424 | 107 | Paul Carensac | compilation terminated. |
425 | 107 | Paul Carensac | error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 |
426 | 107 | Paul Carensac | |
427 | 107 | Paul Carensac | ---------------------------------------- |
428 | 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/ |
429 | 107 | Paul Carensac | |
430 | 108 | Paul Carensac | BOUH !!! |
431 | 108 | Paul Carensac | |
432 | 107 | Paul Carensac | $ sudo apt-get install python3.5-dev |
433 | 108 | Paul Carensac | |
434 | 107 | Paul Carensac | $ pip install mysqlclient |
435 | 107 | Paul Carensac | |
436 | 107 | Paul Carensac | YES !!! |
437 | 107 | Paul Carensac | |
438 | 107 | Paul Carensac | </pre> |
439 | 12 | Etienne Pallier | |
440 | 250 | Paul Carensac | * => Issue under Windows |
441 | 250 | Paul Carensac | <pre> |
442 | 250 | Paul Carensac | Same message as the issue for Mac. |
443 | 250 | Paul Carensac | |
444 | 250 | Paul Carensac | Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient to download the newest mysqlclient wheel |
445 | 250 | Paul Carensac | |
446 | 250 | Paul Carensac | $ pip install path\to\mysqlclient\wheel |
447 | 250 | Paul Carensac | |
448 | 250 | Paul Carensac | No need to redo "pip install mysqlclient" |
449 | 250 | Paul Carensac | </pre> |
450 | 250 | Paul Carensac | |
451 | 12 | Etienne Pallier | --- |
452 | 28 | Etienne Pallier | |
453 | 262 | Etienne Pallier | h3. (Eclipse only) Set the Python3 virtual environment as the project interpreter |
454 | 260 | Etienne Pallier | |
455 | 260 | Etienne Pallier | clic droit sur projet / Properties / PyDev - Interpreter/Grammar : |
456 | 260 | Etienne Pallier | Grammar version : 3 |
457 | 260 | Etienne Pallier | Interpreter : click on « click here to configure an interpreter not listed » |
458 | 260 | Etienne Pallier | click on « New » : |
459 | 260 | Etienne Pallier | - Interpreter name : venv_py35_pyros |
460 | 260 | Etienne Pallier | - Interpreter executable : click on « Browse » |
461 | 260 | Etienne Pallier | Select your private/venv_py35_pyros/bin/python3.5 executable |
462 | 260 | Etienne Pallier | click OK |
463 | 260 | Etienne Pallier | click OK again |
464 | 260 | Etienne Pallier | |
465 | 260 | Etienne Pallier | Interpreter: select now venv_py35_pyros from the list |
466 | 260 | Etienne Pallier | |
467 | 142 | Etienne Pallier | h3. Test the project |
468 | 142 | Etienne Pallier | |
469 | 263 | Etienne Pallier | TODO: more details... |
470 | 263 | Etienne Pallier | |
471 | 142 | Etienne Pallier | <pre> |
472 | 142 | Etienne Pallier | |
473 | 150 | Etienne Pallier | $ cd src/ |
474 | 150 | Etienne Pallier | |
475 | 1 | Etienne Pallier | $ ./manage.py runserver |
476 | 38 | Etienne Pallier | (or gunicorn pyros.wsgi) |
477 | 3 | Etienne Pallier | ==> http://localhost:8000 |
478 | 87 | Etienne Pallier | ... |
479 | 87 | Etienne Pallier | ... |
480 | 87 | Etienne Pallier | Ctrl-c |
481 | 87 | Etienne Pallier | |
482 | 1 | Etienne Pallier | </pre> |
483 | 142 | Etienne Pallier | |
484 | 142 | Etienne Pallier | |
485 | 142 | Etienne Pallier | |
486 | 142 | Etienne Pallier | --- |
487 | 142 | Etienne Pallier | |
488 | 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)% |
489 | 155 | Paul Carensac | |
490 | 155 | Paul Carensac | --- |
491 | 155 | Paul Carensac | |
492 | 155 | Paul Carensac | h3. Back Office setup |
493 | 155 | Paul Carensac | |
494 | 155 | Paul Carensac | * Prerequisites in src/pyros/settings.py : |
495 | 155 | Paul Carensac | |
496 | 155 | Paul Carensac | * INSTALLED_APPS must (at least) contain : |
497 | 155 | Paul Carensac | |
498 | 155 | Paul Carensac | * django.contrib.admin |
499 | 155 | Paul Carensac | * django.contrib.auth |
500 | 155 | Paul Carensac | * django.contrib.contenttypes |
501 | 155 | Paul Carensac | * django.contrib.sessions |
502 | 155 | Paul Carensac | |
503 | 155 | Paul Carensac | * MIDDLEWARES must (at least) contain : |
504 | 155 | Paul Carensac | |
505 | 155 | Paul Carensac | * django.contrib.sessions.middleware.SessionMiddleware |
506 | 155 | Paul Carensac | * django.middleware.common.CommonMiddleware |
507 | 155 | Paul Carensac | * django.contrib.auth.middleware.AuthenticationMiddleware |
508 | 155 | Paul Carensac | |
509 | 155 | Paul Carensac | * At least one 'python manage.py migrate' must have been executed |
510 | 155 | Paul Carensac | |
511 | 155 | Paul Carensac | * Create a superuser for the administration : |
512 | 155 | Paul Carensac | |
513 | 155 | Paul Carensac | <pre> |
514 | 155 | Paul Carensac | $ python manage.py createsuperuser |
515 | 155 | Paul Carensac | </pre> |
516 | 155 | Paul Carensac | |
517 | 156 | Paul Carensac | * For each app of the project, fill the admin.py file : |
518 | 155 | Paul Carensac | |
519 | 155 | Paul Carensac | <pre> |
520 | 155 | Paul Carensac | from django.contrib import admin |
521 | 155 | Paul Carensac | from app.models import Model1, Model2 |
522 | 155 | Paul Carensac | |
523 | 155 | Paul Carensac | admin.site.register(Model1) |
524 | 155 | Paul Carensac | admin.site.register(Model2) |
525 | 155 | Paul Carensac | </pre> |
526 | 155 | Paul Carensac | |
527 | 155 | Paul Carensac | *Reminder* : each application must be registered in the settings.py INSTALLED_APPS variable. |
528 | 157 | Paul Carensac | |
529 | 168 | Paul Carensac | * For each model in models.py, add a '__str__()' method in order to identify the object on the back office. Example : |
530 | 157 | Paul Carensac | |
531 | 157 | Paul Carensac | <pre> |
532 | 157 | Paul Carensac | class UserLevel(models.Model): |
533 | 157 | Paul Carensac | name = models.CharField(max_length=45, blank=True, null=True) |
534 | 157 | Paul Carensac | desc = models.TextField(blank=True, null=True) |
535 | 157 | Paul Carensac | priority = models.IntegerField(blank=True, null=True) |
536 | 157 | Paul Carensac | quota = models.FloatField(blank=True, null=True) |
537 | 157 | Paul Carensac | |
538 | 157 | Paul Carensac | class Meta: |
539 | 157 | Paul Carensac | managed = True |
540 | 157 | Paul Carensac | db_table = 'userlevel' |
541 | 157 | Paul Carensac | |
542 | 157 | Paul Carensac | def __str__(self): |
543 | 163 | Paul Carensac | return (str(self.name)) |
544 | 157 | Paul Carensac | </pre> |
545 | 157 | Paul Carensac | |
546 | 159 | Paul Carensac | *Naming convention* : Use self.name when possible, the creation time/date otherwise. Example : |
547 | 159 | Paul Carensac | |
548 | 159 | Paul Carensac | <pre> |
549 | 159 | Paul Carensac | class SiteWatch(models.Model): |
550 | 159 | Paul Carensac | updated = models.DateTimeField(blank=True, null=True) |
551 | 159 | Paul Carensac | lights = models.CharField(max_length=45, blank=True, null=True) |
552 | 159 | Paul Carensac | dome = models.CharField(max_length=45, blank=True, null=True) |
553 | 159 | Paul Carensac | doors = models.CharField(max_length=45, blank=True, null=True) |
554 | 159 | Paul Carensac | temperature = models.FloatField(blank=True, null=True) |
555 | 159 | Paul Carensac | |
556 | 159 | Paul Carensac | class Meta: |
557 | 159 | Paul Carensac | managed = True |
558 | 159 | Paul Carensac | db_table = 'sitewatch' |
559 | 159 | Paul Carensac | |
560 | 159 | Paul Carensac | def __str__(self): |
561 | 160 | Paul Carensac | return (str(self.updated)) |
562 | 159 | Paul Carensac | </pre> |
563 | 173 | Etienne Pallier | |
564 | 211 | Paul Carensac | --- |
565 | 211 | Paul Carensac | |
566 | 211 | Paul Carensac | h3. Adaptation of the one-to-many and many-to-many display |
567 | 211 | Paul Carensac | |
568 | 211 | Paul Carensac | * The one-to-many relationships are the following (One.many format) : |
569 | 211 | Paul Carensac | |
570 | 211 | Paul Carensac | * Schedule.sequences |
571 | 211 | Paul Carensac | * Request.sequences |
572 | 211 | Paul Carensac | * Sequence.albums |
573 | 211 | Paul Carensac | * Album.plans |
574 | 211 | Paul Carensac | * Plan.images |
575 | 211 | Paul Carensac | * Telescope.detectors |
576 | 211 | Paul Carensac | * Detector.filters |
577 | 211 | Paul Carensac | * NrtAnalysis.images |
578 | 211 | Paul Carensac | * Filter.plans |
579 | 211 | Paul Carensac | * Detector.albums |
580 | 211 | Paul Carensac | * UserLevel.users |
581 | 211 | Paul Carensac | * Country.users |
582 | 211 | Paul Carensac | * ScientificProgram.requests |
583 | 211 | Paul Carensac | * User.requests |
584 | 211 | Paul Carensac | * StrategyObs.alerts |
585 | 211 | Paul Carensac | * SequenceType.sequences |
586 | 211 | Paul Carensac | |
587 | 211 | Paul Carensac | * For each "many", create a new class in admin.py just after the imports, following these examples : |
588 | 211 | Paul Carensac | |
589 | 211 | Paul Carensac | <pre> |
590 | 211 | Paul Carensac | |
591 | 211 | Paul Carensac | For Schedule.sequences, Request.sequences and Sequentype.sequences, we will need : |
592 | 211 | Paul Carensac | |
593 | 211 | Paul Carensac | class SequenceInline(admin.TabularInline): |
594 | 211 | Paul Carensac | model = Sequence |
595 | 211 | Paul Carensac | fields = ("name",) |
596 | 211 | Paul Carensac | show_change_link = True |
597 | 211 | Paul Carensac | |
598 | 211 | Paul Carensac | |
599 | 211 | Paul Carensac | For Sequence.albums and Detector.albums, we will need : |
600 | 211 | Paul Carensac | |
601 | 211 | Paul Carensac | class AlbumInline(admin.TabularInline): |
602 | 211 | Paul Carensac | model = Album |
603 | 211 | Paul Carensac | fields = ("name",) |
604 | 211 | Paul Carensac | show_change_link = True |
605 | 211 | Paul Carensac | |
606 | 211 | Paul Carensac | |
607 | 211 | Paul Carensac | For StrategyObs.alerts, we will need : |
608 | 211 | Paul Carensac | |
609 | 211 | Paul Carensac | class AlertInline(admin.TabularInline): |
610 | 211 | Paul Carensac | model = Alert |
611 | 211 | Paul Carensac | fields = ("request.name",) # there is no 'name' attribute in the Alert model |
612 | 211 | Paul Carensac | show_change_link = True |
613 | 211 | Paul Carensac | |
614 | 211 | Paul Carensac | </pre> |
615 | 211 | Paul Carensac | |
616 | 222 | Paul Carensac | * For each "One", declare a new class in admin.py, just after the "Inlines" class declaration, as done in the following examples : |
617 | 211 | Paul Carensac | |
618 | 222 | Paul Carensac | <pre> |
619 | 222 | Paul Carensac | For Request.sequences : |
620 | 222 | Paul Carensac | |
621 | 222 | Paul Carensac | class RequestAdmin(admin.ModelAdmin): |
622 | 222 | Paul Carensac | inlines = [ |
623 | 222 | Paul Carensac | SequenceInline, |
624 | 222 | Paul Carensac | ] |
625 | 222 | Paul Carensac | |
626 | 222 | Paul Carensac | For Detector.filters and Detector.albums : |
627 | 222 | Paul Carensac | |
628 | 222 | Paul Carensac | class DetectorAdmin(admin.ModelAdmin): |
629 | 222 | Paul Carensac | inlines = [ |
630 | 222 | Paul Carensac | FilterInline, |
631 | 222 | Paul Carensac | AlbumInline, |
632 | 222 | Paul Carensac | ] |
633 | 222 | Paul Carensac | |
634 | 222 | Paul Carensac | </pre> |
635 | 222 | Paul Carensac | |
636 | 232 | Paul Carensac | |
637 | 222 | Paul Carensac | * The many-to-many relationships are the following : |
638 | 232 | Paul Carensac | |
639 | 222 | Paul Carensac | * ScientificProgram - User |
640 | 222 | Paul Carensac | * ScheduleHistory - Sequence |
641 | 222 | Paul Carensac | |
642 | 222 | Paul Carensac | * For each many-to-many relationship, declare a new "Inline" class in admin.py just after the imports, like this : |
643 | 222 | Paul Carensac | |
644 | 222 | Paul Carensac | <pre> |
645 | 222 | Paul Carensac | For ScientificProgram - User : |
646 | 222 | Paul Carensac | |
647 | 222 | Paul Carensac | class UserAndSPInline(admin.TabularInline): |
648 | 222 | Paul Carensac | model = ScientificProgram.users.through |
649 | 222 | Paul Carensac | |
650 | 222 | Paul Carensac | |
651 | 222 | Paul Carensac | For ScheduleHistory - Sequence |
652 | 222 | Paul Carensac | |
653 | 222 | Paul Carensac | class SequenceAndSHInline(admin.TabularInline): |
654 | 222 | Paul Carensac | model = ScheduleHistory.sequences.through |
655 | 222 | Paul Carensac | |
656 | 222 | Paul Carensac | </pre> |
657 | 222 | Paul Carensac | |
658 | 222 | Paul Carensac | +Note :+ The order in the line "model = ScientificProgram.users.through" is very important : the first model (ScientificProgram) is the one in which is declared the ManyToManyField relationship. |
659 | 232 | Paul Carensac | |
660 | 232 | Paul Carensac | * For each many-to-many relationship, declare two new classes in admin.py, just after the inlines, like in the following examples : |
661 | 232 | Paul Carensac | |
662 | 232 | Paul Carensac | <pre> |
663 | 232 | Paul Carensac | For the ScheduleHistory - Sequence relationship : |
664 | 232 | Paul Carensac | |
665 | 232 | Paul Carensac | class ScheduleHistoryAdmin(admin.ModelAdmin): |
666 | 232 | Paul Carensac | inlines = [ |
667 | 232 | Paul Carensac | SequenceAndSHInline, |
668 | 232 | Paul Carensac | ] |
669 | 232 | Paul Carensac | exclude = ('sequences',) # ScheduleHistory declares the ManyToManyField, and we want to replace its display in the back office, so we won't display the default field |
670 | 232 | Paul Carensac | |
671 | 232 | Paul Carensac | class SequenceAdmin(admin.ModelAdmin): |
672 | 232 | Paul Carensac | inlines = [ |
673 | 232 | Paul Carensac | AlbumInline, # This is the Inline for the one-to-many relationship Sequence.albums |
674 | 232 | Paul Carensac | SequenceAndSHInline, |
675 | 232 | Paul Carensac | ] |
676 | 232 | Paul Carensac | |
677 | 232 | Paul Carensac | For the ScientificProgram - User relationship : |
678 | 232 | Paul Carensac | |
679 | 232 | Paul Carensac | class ScientificProgramAdmin(admin.ModelAdmin): |
680 | 232 | Paul Carensac | inlines = [ |
681 | 232 | Paul Carensac | RequestInline, |
682 | 232 | Paul Carensac | UserAndSPInline, |
683 | 232 | Paul Carensac | ] |
684 | 232 | Paul Carensac | exclude = ('users',) # Same as ScheduleHistory |
685 | 232 | Paul Carensac | |
686 | 232 | Paul Carensac | class UserAdmin(admin.ModelAdmin): |
687 | 232 | Paul Carensac | inlines = [ |
688 | 232 | Paul Carensac | RequestInline, # This is the Inline for the one-to-many relationship User.requests |
689 | 232 | Paul Carensac | UserAndSPInline, |
690 | 232 | Paul Carensac | ] |
691 | 232 | Paul Carensac | |
692 | 232 | Paul Carensac | </pre> |
693 | 232 | Paul Carensac | |
694 | 235 | Paul Carensac | * For each ModelAdmin class in the admin.py, change the registering line |
695 | 235 | Paul Carensac | |
696 | 235 | Paul Carensac | <pre> |
697 | 235 | Paul Carensac | admin.site.register(Album) |
698 | 235 | Paul Carensac | </pre> |
699 | 235 | Paul Carensac | |
700 | 235 | Paul Carensac | to |
701 | 235 | Paul Carensac | |
702 | 235 | Paul Carensac | <pre> |
703 | 235 | Paul Carensac | admin.site.register(Album, AlbumAdmin) |
704 | 235 | Paul Carensac | </pre> |
705 | 211 | Paul Carensac | |
706 | 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)% |
707 | 1 | Etienne Pallier | |
708 | 236 | Etienne Pallier | |
709 | 242 | Etienne Pallier | [[pyros_install_from_start|Pyros installation from the beginning]] |