Project Installation

Version 39 (Etienne Pallier, 03/30/2016 06:33 pm)

1 1 Etienne Pallier
h1. Project Installation
2 1 Etienne Pallier
3 6 Etienne Pallier
4 11 Etienne Pallier
Project Development page : [[Project Development]]
5 11 Etienne Pallier
6 6 Etienne Pallier
HOWTO Format Redmine Wiki : http://www.redmine.org/projects/redmine/wiki/FrRedmineWikiFormatting
7 6 Etienne Pallier
8 6 Etienne Pallier
{{>toc}}
9 6 Etienne Pallier
10 6 Etienne Pallier
11 3 Etienne Pallier
---
12 3 Etienne Pallier
13 4 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}I - DATABASE SCHEMA (v0.2.1)%
14 4 Etienne Pallier
15 4 Etienne Pallier
16 4 Etienne Pallier
{{thumbnail(PYROS_PDM_v021.png, size=300, title=Pyros data model)}}
17 4 Etienne Pallier
18 4 Etienne Pallier
19 4 Etienne Pallier
---
20 5 Etienne Pallier
21 5 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}II - Get the project (from gitlab)%
22 5 Etienne Pallier
23 1 Etienne Pallier
24 12 Etienne Pallier
h3. Browse the code from gitlab
25 5 Etienne Pallier
26 12 Etienne Pallier
https://gitlab.irap.omp.eu/epallier/pyros/tree/master
27 5 Etienne Pallier
28 5 Etienne Pallier
h3. Project structure
29 5 Etienne Pallier
30 5 Etienne Pallier
Once you have fetched the project, you should obtain this structure:
31 5 Etienne Pallier
32 5 Etienne Pallier
<pre>
33 5 Etienne Pallier
34 5 Etienne Pallier
PYROS/
35 5 Etienne Pallier
├── install/
36 5 Etienne Pallier
│   └── REQUIREMENTS.txt
37 5 Etienne Pallier
│   └── INSTALLATION.txt
38 5 Etienne Pallier
├── public/
39 5 Etienne Pallier
│   └── static/
40 5 Etienne Pallier
├── src/
41 5 Etienne Pallier
│   ├── manage.py
42 5 Etienne Pallier
│   ├── pyros/
43 5 Etienne Pallier
│   │   ├── __init__.py
44 5 Etienne Pallier
│   │   ├── __pycache__
45 5 Etienne Pallier
│   │   ├── settings.py
46 5 Etienne Pallier
│   │   ├── urls.py
47 5 Etienne Pallier
│   │   └── wsgi.py
48 5 Etienne Pallier
│   └── pyrosapp/
49 5 Etienne Pallier
│       ├── __init__.py
50 5 Etienne Pallier
│       ├── admin.py
51 5 Etienne Pallier
│       ├── apps.py
52 5 Etienne Pallier
│       ├── migrations
53 5 Etienne Pallier
│       ├── models.py
54 5 Etienne Pallier
│       ├── tests.py
55 5 Etienne Pallier
│       └── views.py
56 5 Etienne Pallier
57 5 Etienne Pallier
58 5 Etienne Pallier
</pre>
59 5 Etienne Pallier
60 37 Etienne Pallier
h3. From Eclipse
61 37 Etienne Pallier
62 37 Etienne Pallier
See below, section "NOTES FOR ECLIPSE USERS"
63 37 Etienne Pallier
64 37 Etienne Pallier
65 5 Etienne Pallier
h3. From the terminal
66 5 Etienne Pallier
67 5 Etienne Pallier
<pre>
68 5 Etienne Pallier
git clone https://gitlab.irap.omp.eu/epallier/pyros.git PYROS
69 5 Etienne Pallier
(or also : git clone git@gitlab.irap.omp.eu:epallier/pyros.git PYROS)
70 5 Etienne Pallier
</pre>
71 5 Etienne Pallier
72 5 Etienne Pallier
This creates a PYROS/ folder containing the project (with a .git/ subfolder for synchronization with the git repository)
73 5 Etienne Pallier
74 5 Etienne Pallier
_If you just wanted a static copy of the project (without synchronization), just remove the .git/ folder:_
75 5 Etienne Pallier
<pre>
76 5 Etienne Pallier
$ rm -r .git/
77 5 Etienne Pallier
</pre>
78 5 Etienne Pallier
79 38 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}III - INSTALLATION OF NEEDED DEPENDANCES%
80 9 Etienne Pallier
81 9 Etienne Pallier
82 9 Etienne Pallier
---
83 1 Etienne Pallier
84 38 Etienne Pallier
h3. Install a database server (only if necessary)
85 38 Etienne Pallier
86 38 Etienne Pallier
By default, 
87 38 Etienne Pallier
MySql (only if necessary)
88 26 Etienne Pallier
89 26 Etienne Pallier
*Skip this step if you are using Sqlite instead of MySql*
90 9 Etienne Pallier
91 9 Etienne Pallier
 * Linux Ubuntu
92 9 Etienne Pallier
<pre>
93 9 Etienne Pallier
94 9 Etienne Pallier
$ sudo apt-get install mysql-server
95 9 Etienne Pallier
$ sudo apt-get install mysql-client
96 9 Etienne Pallier
97 9 Etienne Pallier
</pre>
98 9 Etienne Pallier
99 9 Etienne Pallier
 * Linux CentOS
100 9 Etienne Pallier
<pre>
101 9 Etienne Pallier
TODO:
102 9 Etienne Pallier
$ sudo yum install mysql
103 9 Etienne Pallier
...
104 9 Etienne Pallier
</pre>
105 9 Etienne Pallier
106 9 Etienne Pallier
 * Mac OS X
107 9 Etienne Pallier
Install XAMPP
108 9 Etienne Pallier
(but you could also use the pre-installed Mac OS MySql)
109 9 Etienne Pallier
<pre>
110 9 Etienne Pallier
TODO:
111 9 Etienne Pallier
</pre>
112 9 Etienne Pallier
113 9 Etienne Pallier
 * Windows
114 9 Etienne Pallier
115 9 Etienne Pallier
<pre>
116 9 Etienne Pallier
Download and install the newest version on https://dev.mysql.com/downloads/installer/
117 9 Etienne Pallier
118 9 Etienne Pallier
Once installed, launch MySQL Installer. Clic on 'Add...' on the right.
119 9 Etienne Pallier
In MySQLServers section, choose the newest, then clic on next.
120 9 Etienne Pallier
Install and configure the server (just follow the installation guide).
121 9 Etienne Pallier
122 9 Etienne Pallier
Then launch mysql (via the Windows menu).
123 9 Etienne Pallier
</pre>
124 9 Etienne Pallier
125 9 Etienne Pallier
126 9 Etienne Pallier
---
127 9 Etienne Pallier
128 9 Etienne Pallier
h3. Install Python3.5 (only if necessary)
129 9 Etienne Pallier
130 9 Etienne Pallier
131 9 Etienne Pallier
 * Mac OS X :
132 9 Etienne Pallier
<pre>
133 9 Etienne Pallier
134 9 Etienne Pallier
1) Installer MacPort
135 9 Etienne Pallier
(TODO: doc)
136 9 Etienne Pallier
137 9 Etienne Pallier
2) Installer le "port" python35
138 9 Etienne Pallier
$ sudo port install python35
139 9 Etienne Pallier
140 9 Etienne Pallier
</pre>
141 9 Etienne Pallier
142 9 Etienne Pallier
 * Linux (Ubuntu) :
143 9 Etienne Pallier
<pre>
144 9 Etienne Pallier
$ sudo add-apt-repository ppa:fkrull/deadsnakes
145 9 Etienne Pallier
$ sudo apt-get update
146 9 Etienne Pallier
$ sudo apt-get install python3.5
147 9 Etienne Pallier
148 9 Etienne Pallier
$ sudo pip install virtualenv
149 9 Etienne Pallier
</pre>
150 9 Etienne Pallier
151 9 Etienne Pallier
152 9 Etienne Pallier
 * Windows 7 :
153 9 Etienne Pallier
<pre>
154 9 Etienne Pallier
Go to https://www.python.org/downloads/windows/ , choose the wanted version
155 9 Etienne Pallier
On the wanted version’s page, download Windows x86 executable installer
156 9 Etienne Pallier
157 9 Etienne Pallier
Run the executable
158 9 Etienne Pallier
    * On the first page, check "Add python3.5 to PATH"
159 9 Etienne Pallier
    * Choose "Install now" option
160 9 Etienne Pallier
161 9 Etienne Pallier
Open cmd (windows + R, cmd) :
162 9 Etienne Pallier
 $ python -m pip install --upgrade pip
163 9 Etienne Pallier
 $ pip install virtualenv
164 9 Etienne Pallier
</pre>
165 9 Etienne Pallier
166 9 Etienne Pallier
 * Windows 10 :
167 9 Etienne Pallier
<pre>
168 9 Etienne Pallier
TODO:
169 9 Etienne Pallier
</pre>
170 9 Etienne Pallier
171 9 Etienne Pallier
---
172 9 Etienne Pallier
173 9 Etienne Pallier
h3. Create a Python3 virtual environment dedicated to the project (inside the project folder)
174 9 Etienne Pallier
175 9 Etienne Pallier
<pre>
176 9 Etienne Pallier
177 9 Etienne Pallier
$ mkdir private/
178 9 Etienne Pallier
179 9 Etienne Pallier
$ cd private/
180 9 Etienne Pallier
181 9 Etienne Pallier
$ which python3.5 ("where python" for windows)
182 9 Etienne Pallier
/opt/local/bin/python3.5
183 9 Etienne Pallier
184 9 Etienne Pallier
$ virtualenv-3.5 venv_py35_pyros -p /opt/local/bin/python3.5
185 9 Etienne Pallier
=> creates a venv_py35_pyros/ folder inside PYROS/private/
186 9 Etienne Pallier
187 9 Etienne Pallier
</pre>
188 9 Etienne Pallier
189 9 Etienne Pallier
---
190 9 Etienne Pallier
191 9 Etienne Pallier
h3. Activate the python virtual environment (from inside the project)
192 9 Etienne Pallier
193 9 Etienne Pallier
<pre>
194 9 Etienne Pallier
195 9 Etienne Pallier
$ pwd
196 9 Etienne Pallier
.../PYROS/private
197 9 Etienne Pallier
198 9 Etienne Pallier
$ source ./venv_py35_pyros/bin/activate (venv_py35_pyros/Scripts/activate on Windows)
199 9 Etienne Pallier
200 9 Etienne Pallier
201 9 Etienne Pallier
$ python -V
202 9 Etienne Pallier
Python 3.5.1
203 9 Etienne Pallier
204 9 Etienne Pallier
$ which pip
205 9 Etienne Pallier
.../PYROS/venv_py35_pyros/bin/pip
206 9 Etienne Pallier
207 9 Etienne Pallier
Upgrade pip to last version available:
208 9 Etienne Pallier
$ pip install --upgrade pip
209 9 Etienne Pallier
Collecting pip
210 9 Etienne Pallier
  Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB)
211 9 Etienne Pallier
Installing collected packages: pip
212 9 Etienne Pallier
  Found existing installation: pip 7.1.2
213 9 Etienne Pallier
    Uninstalling pip-7.1.2:
214 9 Etienne Pallier
      Successfully uninstalled pip-7.1.2
215 9 Etienne Pallier
Successfully installed pip-8.1.1
216 9 Etienne Pallier
217 9 Etienne Pallier
Upgrade wheel to last version available:
218 9 Etienne Pallier
$ pip install --upgrade wheel
219 9 Etienne Pallier
Collecting wheel
220 9 Etienne Pallier
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
221 9 Etienne Pallier
Installing collected packages: wheel
222 9 Etienne Pallier
  Found existing installation: wheel 0.24.0
223 9 Etienne Pallier
    Uninstalling wheel-0.24.0:
224 9 Etienne Pallier
      Successfully uninstalled wheel-0.24.0
225 9 Etienne Pallier
Successfully installed wheel-0.29.0
226 9 Etienne Pallier
227 9 Etienne Pallier
228 9 Etienne Pallier
</pre>
229 9 Etienne Pallier
230 9 Etienne Pallier
---
231 9 Etienne Pallier
232 9 Etienne Pallier
h3. Install the needed Python packages (from within the virtual environment)
233 9 Etienne Pallier
234 9 Etienne Pallier
First, be sure that the virtual environment is activated:
235 9 Etienne Pallier
<pre>
236 9 Etienne Pallier
$ python -V
237 9 Etienne Pallier
Python 3.5.1
238 9 Etienne Pallier
</pre>
239 9 Etienne Pallier
240 9 Etienne Pallier
 * *Automatic Installation of all packages*
241 9 Etienne Pallier
<pre>
242 9 Etienne Pallier
$ pip install -r REQUIREMENTS.txt
243 9 Etienne Pallier
</pre>
244 9 Etienne Pallier
245 9 Etienne Pallier
 * *Or, manual installation of each package*
246 9 Etienne Pallier
247 9 Etienne Pallier
  * *Install Django* :
248 9 Etienne Pallier
<pre>
249 9 Etienne Pallier
$ pip install django
250 9 Etienne Pallier
Collecting django
251 9 Etienne Pallier
  Downloading Django-1.9.4-py2.py3-none-any.whl (6.6MB)
252 9 Etienne Pallier
Installing collected packages: django
253 9 Etienne Pallier
Successfully installed django-1.9.4
254 9 Etienne Pallier
255 9 Etienne Pallier
$ pip install django-admin-tools
256 9 Etienne Pallier
Collecting django-admin-tools
257 9 Etienne Pallier
  Downloading django_admin_tools-0.7.2-py2.py3-none-any.whl (289kB)
258 9 Etienne Pallier
Installing collected packages: django-admin-tools
259 9 Etienne Pallier
Successfully installed django-admin-tools-0.7.2
260 9 Etienne Pallier
261 9 Etienne Pallier
$ pip install django-debug-toolbar
262 9 Etienne Pallier
Collecting django-debug-toolbar
263 9 Etienne Pallier
  Downloading django_debug_toolbar-1.4-py2.py3-none-any.whl (212kB)
264 9 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)
265 9 Etienne Pallier
Collecting sqlparse (from django-debug-toolbar)
266 9 Etienne Pallier
  Downloading sqlparse-0.1.19.tar.gz (58kB)
267 9 Etienne Pallier
Building wheels for collected packages: sqlparse
268 9 Etienne Pallier
  Running setup.py bdist_wheel for sqlparse ... done
269 9 Etienne Pallier
  Stored in directory: /Users/epallier/Library/Caches/pip/wheels/7b/d4/72/6011bb100dd5fc213164e4bbee13d4e03261dd54ce6a5de6b8
270 9 Etienne Pallier
Successfully built sqlparse
271 9 Etienne Pallier
Installing collected packages: sqlparse, django-debug-toolbar
272 9 Etienne Pallier
Successfully installed django-debug-toolbar-1.4 sqlparse-0.1.19
273 9 Etienne Pallier
274 9 Etienne Pallier
$ pip install django-extensions
275 9 Etienne Pallier
Collecting django-extensions
276 9 Etienne Pallier
  Downloading django_extensions-1.6.1-py2.py3-none-any.whl (202kB)
277 9 Etienne Pallier
Collecting six>=1.2 (from django-extensions)
278 9 Etienne Pallier
  Downloading six-1.10.0-py2.py3-none-any.whl
279 9 Etienne Pallier
Installing collected packages: six, django-extensions
280 9 Etienne Pallier
Successfully installed django-extensions-1.6.1 six-1.10.0
281 9 Etienne Pallier
282 9 Etienne Pallier
$ pip install django-suit
283 9 Etienne Pallier
Collecting django-suit
284 9 Etienne Pallier
  Downloading django-suit-0.2.18.tar.gz (587kB)
285 9 Etienne Pallier
Building wheels for collected packages: django-suit
286 9 Etienne Pallier
  Running setup.py bdist_wheel for django-suit ... done
287 9 Etienne Pallier
  Stored in directory: /Users/epallier/Library/Caches/pip/wheels/12/8b/9a/e02ab0ad9229881638aa040d47d77c8f562999533811927d41
288 9 Etienne Pallier
Successfully built django-suit
289 9 Etienne Pallier
Installing collected packages: django-suit
290 9 Etienne Pallier
Successfully installed django-suit-0.2.18
291 9 Etienne Pallier
292 9 Etienne Pallier
</pre>
293 9 Etienne Pallier
294 30 Paul Carensac
  * *Install the django boostrap css package* :
295 30 Paul Carensac
<pre>
296 30 Paul Carensac
$ pip install django-bootstrap3
297 30 Paul Carensac
</pre>
298 30 Paul Carensac
==> You need to add 'bootstrap3' in settings.py -> INSTALLED_APPS
299 30 Paul Carensac
300 9 Etienne Pallier
  * *Install the web application server gunicorn (will be used in production instead of the dev django web server)* :
301 9 Etienne Pallier
<pre>
302 9 Etienne Pallier
$ pip install gunicorn
303 9 Etienne Pallier
Collecting gunicorn
304 9 Etienne Pallier
  Downloading gunicorn-19.4.5-py2.py3-none-any.whl (112kB)
305 9 Etienne Pallier
Installing collected packages: gunicorn
306 9 Etienne Pallier
Successfully installed gunicorn-19.4.5
307 9 Etienne Pallier
</pre>
308 1 Etienne Pallier
309 30 Paul Carensac
  * *Install the python mysql client* (not needed if you want to use sqlite):
310 9 Etienne Pallier
<pre>
311 9 Etienne Pallier
$ pip install mysqlclient
312 9 Etienne Pallier
...
313 9 Etienne Pallier
</pre>
314 9 Etienne Pallier
315 9 Etienne Pallier
   * => Issue under Mac OS X:
316 9 Etienne Pallier
<pre>
317 9 Etienne Pallier
$ pip install mysqlclient
318 9 Etienne Pallier
Collecting mysqlclient
319 9 Etienne Pallier
  Downloading mysqlclient-1.3.7.tar.gz (79kB)
320 9 Etienne Pallier
Building wheels for collected packages: mysqlclient
321 9 Etienne Pallier
  Running setup.py bdist_wheel for mysqlclient ... error
322 9 Etienne Pallier
323 9 Etienne Pallier
  ----------------------------------------
324 9 Etienne Pallier
  Failed building wheel for mysqlclient
325 9 Etienne Pallier
  Running setup.py clean for mysqlclient
326 9 Etienne Pallier
Failed to build mysqlclient
327 9 Etienne Pallier
Installing collected packages: mysqlclient
328 9 Etienne Pallier
  Running setup.py install for mysqlclient ... done
329 9 Etienne Pallier
Successfully installed mysqlclient-1.3.7
330 9 Etienne Pallier
331 9 Etienne Pallier
BOUH !!!
332 9 Etienne Pallier
333 9 Etienne Pallier
$ pip install --upgrade wheel
334 9 Etienne Pallier
Collecting wheel
335 9 Etienne Pallier
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
336 9 Etienne Pallier
Installing collected packages: wheel
337 9 Etienne Pallier
  Found existing installation: wheel 0.24.0
338 9 Etienne Pallier
    Uninstalling wheel-0.24.0:
339 9 Etienne Pallier
      Successfully uninstalled wheel-0.24.0
340 9 Etienne Pallier
Successfully installed wheel-0.29.0
341 9 Etienne Pallier
342 9 Etienne Pallier
$ pip uninstall mysqlclient
343 9 Etienne Pallier
344 9 Etienne Pallier
$ pip install mysqlclient
345 9 Etienne Pallier
Collecting mysqlclient
346 9 Etienne Pallier
  Using cached mysqlclient-1.3.7.tar.gz
347 9 Etienne Pallier
Building wheels for collected packages: mysqlclient
348 9 Etienne Pallier
  Running setup.py bdist_wheel for mysqlclient ... done
349 9 Etienne Pallier
  Stored in directory: /Users/epallier/Library/Caches/pip/wheels/9b/06/50/d11418c26cf8f2156b13d4363b5afde8e7e75ebb8540d0228d
350 9 Etienne Pallier
Successfully built mysqlclient
351 9 Etienne Pallier
Installing collected packages: mysqlclient
352 9 Etienne Pallier
Successfully installed mysqlclient-1.3.7
353 9 Etienne Pallier
354 9 Etienne Pallier
YES !!!
355 9 Etienne Pallier
356 9 Etienne Pallier
</pre>
357 9 Etienne Pallier
358 9 Etienne Pallier
   * => Issues under Ubuntu:
359 9 Etienne Pallier
<pre>
360 9 Etienne Pallier
$ pip install mysqlclient
361 9 Etienne Pallier
Collecting mysqlclient
362 9 Etienne Pallier
  Downloading mysqlclient-1.3.7.tar.gz (79kB)
363 9 Etienne Pallier
    Complete output from command python setup.py egg_info:
364 9 Etienne Pallier
    /bin/sh: 1: mysql_config: not found
365 9 Etienne Pallier
    Traceback (most recent call last):
366 9 Etienne Pallier
      File "<string>", line 1, in <module>
367 9 Etienne Pallier
    [...]
368 9 Etienne Pallier
    ----------------------------------------
369 9 Etienne Pallier
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-q6j4inuz/mysqlclient/
370 9 Etienne Pallier
371 9 Etienne Pallier
BOUH !!!
372 9 Etienne Pallier
373 9 Etienne Pallier
$ sudo apt-get install libmysqlclient-dev
374 9 Etienne Pallier
375 9 Etienne Pallier
$ pip install mysqlclient
376 9 Etienne Pallier
Collecting mysqlclient
377 9 Etienne Pallier
  Using cached mysqlclient-1.3.7.tar.gz
378 9 Etienne Pallier
Building wheels for collected packages: mysqlclient
379 9 Etienne Pallier
  Running setup.py bdist_wheel for mysqlclient ... error
380 9 Etienne Pallier
381 9 Etienne Pallier
    _mysql.c:40:20: fatal error: Python.h: No such file or directory
382 9 Etienne Pallier
     #include "Python.h"
383 9 Etienne Pallier
                        ^
384 9 Etienne Pallier
    compilation terminated.
385 9 Etienne Pallier
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
386 9 Etienne Pallier
    
387 9 Etienne Pallier
    ----------------------------------------
388 9 Etienne Pallier
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/
389 9 Etienne Pallier
390 9 Etienne Pallier
BOUH !!!
391 9 Etienne Pallier
392 9 Etienne Pallier
$ sudo apt-get install python3.5-dev
393 9 Etienne Pallier
394 9 Etienne Pallier
$ pip install mysqlclient
395 9 Etienne Pallier
396 9 Etienne Pallier
YES !!!
397 9 Etienne Pallier
398 1 Etienne Pallier
</pre>
399 9 Etienne Pallier
400 30 Paul Carensac
   * => Issue under Windows
401 9 Etienne Pallier
<pre>
402 9 Etienne Pallier
Same message as the issue for Mac.
403 9 Etienne Pallier
404 9 Etienne Pallier
Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient to download the newest mysqlclient wheel
405 9 Etienne Pallier
406 9 Etienne Pallier
$ pip install path\to\mysqlclient\wheel
407 9 Etienne Pallier
408 9 Etienne Pallier
No need to redo "pip install mysqlclient"
409 9 Etienne Pallier
</pre>
410 9 Etienne Pallier
411 9 Etienne Pallier
---
412 9 Etienne Pallier
413 9 Etienne Pallier
h3. (Eclipse only) Set the Python3 virtual environment as the project interpreter
414 9 Etienne Pallier
415 9 Etienne Pallier
clic droit sur projet / Properties / PyDev - Interpreter/Grammar :
416 9 Etienne Pallier
Grammar version : 3
417 9 Etienne Pallier
418 9 Etienne Pallier
Interpreter : click on « click here to configure an interpreter not listed »
419 9 Etienne Pallier
420 32 Etienne Pallier
click on « New... » :
421 9 Etienne Pallier
- Interpreter name : venv_py35_pyros
422 9 Etienne Pallier
- Interpreter executable : click on « Browse »
423 32 Etienne Pallier
	Select your virtualenv python35 executable (private/venv_py35_pyros/bin/python3.5)
424 1 Etienne Pallier
	click OK
425 1 Etienne Pallier
426 32 Etienne Pallier
*Now, a last thing to do so that Pydev finds Django:*
427 32 Etienne Pallier
428 32 Etienne Pallier
In the Python interpreters list, select your virtual env (venv_py35_pyros)
429 32 Etienne Pallier
430 32 Etienne Pallier
Click on the tab "Libraries"
431 32 Etienne Pallier
432 32 Etienne Pallier
clic on 'New folder', then select your virtualenv's lib/python3.5/site-packages folder
433 32 Etienne Pallier
434 32 Etienne Pallier
OK
435 32 Etienne Pallier
436 9 Etienne Pallier
Interpreter: select now venv_py35_pyros from the list
437 32 Etienne Pallier
438 32 Etienne Pallier
OK
439 9 Etienne Pallier
440 9 Etienne Pallier
---
441 9 Etienne Pallier
442 9 Etienne Pallier
h3. Run the project
443 9 Etienne Pallier
444 9 Etienne Pallier
TODO: more details... (notamment sur localhost:8000/admin)
445 9 Etienne Pallier
446 9 Etienne Pallier
h4. From the terminal
447 9 Etienne Pallier
448 9 Etienne Pallier
<pre>
449 9 Etienne Pallier
450 9 Etienne Pallier
$ cd src/
451 9 Etienne Pallier
452 9 Etienne Pallier
$ ./manage.py runserver
453 9 Etienne Pallier
(or gunicorn pyros.wsgi)
454 9 Etienne Pallier
==> http://localhost:8000
455 9 Etienne Pallier
...
456 9 Etienne Pallier
...
457 9 Etienne Pallier
Ctrl-c
458 9 Etienne Pallier
459 9 Etienne Pallier
</pre>
460 9 Etienne Pallier
461 9 Etienne Pallier
h4. From Eclipse
462 9 Etienne Pallier
463 9 Etienne Pallier
Right clic on project -> Django/Custom command/runserver
464 9 Etienne Pallier
465 9 Etienne Pallier
Error on Ubuntu :
466 9 Etienne Pallier
467 9 Etienne Pallier
<pre>
468 9 Etienne Pallier
469 9 Etienne Pallier
Traceback (most recent call last):
470 9 Etienne Pallier
  File "/home/carens_p/git/pyros/src/manage.py", line 8, in <module>
471 9 Etienne Pallier
    from django.core.management import execute_from_command_line
472 9 Etienne Pallier
ImportError: No module named 'django'
473 9 Etienne Pallier
474 9 Etienne Pallier
</pre>
475 9 Etienne Pallier
476 9 Etienne Pallier
Project -> Properties -> Pydev interpreter -> Clic here to configure an interpreter not listed
477 9 Etienne Pallier
478 9 Etienne Pallier
select venv_py35_pyros
479 9 Etienne Pallier
480 9 Etienne Pallier
In Libraries, clic on 'New folder', then select your virtualenv's lib/python3.5/site-packages folder.
481 9 Etienne Pallier
482 9 Etienne Pallier
OK -> re-select venv_py35_pyros in 'Interpreter' dropdown menu
483 9 Etienne Pallier
484 9 Etienne Pallier
Then right clic on project -> Django/Custom command/runserver
485 9 Etienne Pallier
486 9 Etienne Pallier
check http://localhost:8000/
487 9 Etienne Pallier
488 9 Etienne Pallier
489 9 Etienne Pallier
---
490 17 Etienne Pallier
491 17 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}IV - TEST%
492 17 Etienne Pallier
493 25 Paul Carensac
Tests are classes declared in all apps' test.py file. The test classes inherit from django.test.TestCase
494 17 Etienne Pallier
495 17 Etienne Pallier
You can run the tests suite, just to be sure that the software is well installed.
496 17 Etienne Pallier
497 19 Etienne Pallier
h3. From Terminal
498 19 Etienne Pallier
499 19 Etienne Pallier
500 1 Etienne Pallier
<pre>
501 20 Etienne Pallier
$ cd src/
502 20 Etienne Pallier
503 20 Etienne Pallier
$ ./manage.py test
504 21 Etienne Pallier
505 21 Etienne Pallier
Ran 5 tests in 0.093s
506 21 Etienne Pallier
507 21 Etienne Pallier
OK
508 17 Etienne Pallier
</pre>
509 19 Etienne Pallier
510 19 Etienne Pallier
h3. From Eclipse:
511 1 Etienne Pallier
512 25 Paul Carensac
* Right-clic on the project / Django / Run Django tests
513 25 Paul Carensac
514 25 Paul Carensac
* Right-clic on the project / Django / Custom command / ...
515 25 Paul Carensac
516 27 Paul Carensac
h3. Custom commands :
517 27 Paul Carensac
518 25 Paul Carensac
$ [./manage.py] test app.tests                           # Run tests for the application 'app'
519 25 Paul Carensac
$ [./manage.py] test app.tests.ModelTests                # Run test methods declared in the class app.tests.ModelTests
520 25 Paul Carensac
$ [./manage.py] test app.tests.ModelTests.test_method    # Only run the method test_method declared in app.tests.ModelTests
521 33 Etienne Pallier
522 33 Etienne Pallier
523 33 Etienne Pallier
---
524 33 Etienne Pallier
525 33 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}NOTES FOR ECLIPSE USERS%
526 35 Etienne Pallier
527 35 Etienne Pallier
0) Install Eclipse (if necessary)
528 35 Etienne Pallier
529 35 Etienne Pallier
Get the Eclipse version for Php
530 35 Etienne Pallier
531 35 Etienne Pallier
Install the plug-in pydev (via install new software, add http://pydev.org/updates)
532 35 Etienne Pallier
533 35 Etienne Pallier
Install the django template editor (via install new software, add http://eclipse.kacprzak.org/updates)
534 35 Etienne Pallier
535 35 Etienne Pallier
1) Deactivate CA certificate verification
536 35 Etienne Pallier
537 35 Etienne Pallier
Window -> Preferences -> Team -> git -> configuration -> Add entry
538 35 Etienne Pallier
539 35 Etienne Pallier
Key = http.sslVerify
540 35 Etienne Pallier
Value = false
541 35 Etienne Pallier
542 35 Etienne Pallier
2) Fetch the project
543 35 Etienne Pallier
544 35 Etienne Pallier
File/Import project from git
545 35 Etienne Pallier
546 35 Etienne Pallier
Select repository source: Clone URI: https://gitlab.irap.omp.eu/epallier/pyros.git
547 35 Etienne Pallier
548 35 Etienne Pallier
Directory: 
549 35 Etienne Pallier
par défaut, il propose : /Users/epallier/git/pyros
550 35 Etienne Pallier
mais on peut le mettre ailleurs (c'est ce que j'ai fait)
551 35 Etienne Pallier
552 35 Etienne Pallier
initial branch: master
553 35 Etienne Pallier
remote name: origin
554 35 Etienne Pallier
555 35 Etienne Pallier
Import as general project
556 35 Etienne Pallier
557 35 Etienne Pallier
Project name: PYROS
558 35 Etienne Pallier
559 35 Etienne Pallier
560 35 Etienne Pallier
3) Configure the project
561 35 Etienne Pallier
562 35 Etienne Pallier
The project is created. Now, you have to set it as a «PyDev » and a « Django » project.
563 35 Etienne Pallier
564 35 Etienne Pallier
clic droit sur le projet / PyDev / set as a PyDev project
565 35 Etienne Pallier
566 35 Etienne Pallier
clic droit sur le projet / PyDev / set as a Django project
567 35 Etienne Pallier
568 35 Etienne Pallier
clic droit sur le projet : on doit maintenant avoir un sous-menu Django
569 35 Etienne Pallier
570 35 Etienne Pallier
clic droit sur le dossier src / PyDev / set as source folder (add to PYTHONPATH)
571 35 Etienne Pallier
572 35 Etienne Pallier
clic droit sur projet / Properties / Pydev-Django :
573 35 Etienne Pallier
  - Django manage.py : src/manage.py
574 35 Etienne Pallier
  - Django settings module : pyros.settings
575 35 Etienne Pallier
576 35 Etienne Pallier
577 35 Etienne Pallier
4) Set Code style
578 35 Etienne Pallier
579 35 Etienne Pallier
Window/Preferences : Pydev / Editor
580 35 Etienne Pallier
- Auto Imports : uncheck « Do auto import »
581 35 Etienne Pallier
- Code style:
582 35 Etienne Pallier
	- Locals … : camelCase
583 35 Etienne Pallier
	- Methods : camelCase() with first lower
584 35 Etienne Pallier
- Code style / Code Formatter: activer « use autopep8.py for code formatting »
585 35 Etienne Pallier
- Tabs : Tab length : 4
586 35 Etienne Pallier
587 35 Etienne Pallier
(
588 35 Etienne Pallier
il faudra aussi faire un peu plus loin : 
589 35 Etienne Pallier
https://projects.irap.omp.eu/projects/pyros/wiki/Project_Installation#Eclipse-only-Set-the-Python3-virtual-environment-as-the-project-interpreter
590 35 Etienne Pallier
)