Project Installation

Version 172 (Etienne Pallier, 04/27/2016 12:03 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 170 Etienne Pallier
---
14 170 Etienne Pallier
15 4 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}I - DATABASE SCHEMA (v0.2.1)%
16 4 Etienne Pallier
17 4 Etienne Pallier
18 4 Etienne Pallier
{{thumbnail(PYROS_PDM_v021.png, size=300, title=Pyros data model)}}
19 4 Etienne Pallier
20 4 Etienne Pallier
21 4 Etienne Pallier
---
22 5 Etienne Pallier
23 170 Etienne Pallier
---
24 170 Etienne Pallier
25 113 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}II - GET THE PYROS SOFTWARE%
26 5 Etienne Pallier
27 125 Etienne Pallier
h3. Authenticate to https://gitlab.irap.omp.eu/epallier/pyros
28 125 Etienne Pallier
29 125 Etienne Pallier
In order to get this software, you must first authenticate on the IRAP gitlab.
30 125 Etienne Pallier
31 125 Etienne Pallier
For this, just go to https://gitlab.irap.omp.eu/epallier/pyros
32 125 Etienne Pallier
and either sign in with your LDAP account (if you are from IRAP),
33 125 Etienne Pallier
or register via the "Sign up" form.
34 5 Etienne Pallier
35 113 Etienne Pallier
h3. Software structure
36 5 Etienne Pallier
37 156 Paul Carensac
Once you have fetched the project, you should obtain AT LEAST this structure:
38 5 Etienne Pallier
39 5 Etienne Pallier
<pre>
40 5 Etienne Pallier
41 5 Etienne Pallier
PYROS/
42 5 Etienne Pallier
├── install/
43 5 Etienne Pallier
│   └── REQUIREMENTS.txt
44 5 Etienne Pallier
│   └── INSTALLATION.txt
45 5 Etienne Pallier
├── public/
46 5 Etienne Pallier
│   └── static/
47 5 Etienne Pallier
├── src/
48 5 Etienne Pallier
│   ├── manage.py
49 5 Etienne Pallier
│   ├── pyros/
50 5 Etienne Pallier
│   │   ├── __init__.py
51 5 Etienne Pallier
│   │   ├── __pycache__
52 5 Etienne Pallier
│   │   ├── settings.py
53 5 Etienne Pallier
│   │   ├── urls.py
54 5 Etienne Pallier
│   │   └── wsgi.py
55 5 Etienne Pallier
│   └── pyrosapp/
56 5 Etienne Pallier
│       ├── __init__.py
57 5 Etienne Pallier
│       ├── admin.py
58 5 Etienne Pallier
│       ├── apps.py
59 5 Etienne Pallier
│       ├── migrations
60 5 Etienne Pallier
│       ├── models.py
61 5 Etienne Pallier
│       ├── tests.py
62 5 Etienne Pallier
│       └── views.py
63 5 Etienne Pallier
64 1 Etienne Pallier
65 1 Etienne Pallier
</pre>
66 1 Etienne Pallier
67 112 Etienne Pallier
h3. Browse the code (from gitlab)
68 111 Etienne Pallier
69 111 Etienne Pallier
https://gitlab.irap.omp.eu/epallier/pyros/tree/master
70 111 Etienne Pallier
71 113 Etienne Pallier
h3. Download it (static version, not synchronized)
72 111 Etienne Pallier
73 114 Etienne Pallier
You can download the current version of the software.
74 114 Etienne Pallier
75 115 Etienne Pallier
Go to https://gitlab.irap.omp.eu/epallier/pyros/tree/master
76 115 Etienne Pallier
77 115 Etienne Pallier
Click on "Download zip" on the up right hand corner.
78 115 Etienne Pallier
79 115 Etienne Pallier
Double-click on it to unzip it.
80 115 Etienne Pallier
81 115 Etienne Pallier
You should get a "pyros.git" folder.
82 115 Etienne Pallier
83 116 Etienne Pallier
In this documentation, this software folder will be referenced as "PYROS".
84 115 Etienne Pallier
85 118 Etienne Pallier
(you can rename "pyros.git" as "PYROS" if you want : "mv pyros.git PYROS")
86 114 Etienne Pallier
87 113 Etienne Pallier
h3. Get it from GIT (dynamic version, synchronized)
88 114 Etienne Pallier
89 122 Etienne Pallier
(If you are using Windows, you must first get the git software, see below "Get git for Windows")
90 122 Etienne Pallier
91 114 Etienne Pallier
By getting the software from git, you will get a dynamically synchronized version,
92 114 Etienne Pallier
which means that you will be able to update your version as soon as a new version is available
93 114 Etienne Pallier
(with the command : "git pull").
94 111 Etienne Pallier
95 111 Etienne Pallier
* From Eclipse : See below, section "NOTES FOR ECLIPSE USERS"
96 111 Etienne Pallier
97 111 Etienne Pallier
* From the terminal
98 5 Etienne Pallier
99 5 Etienne Pallier
<pre>
100 5 Etienne Pallier
git clone https://gitlab.irap.omp.eu/epallier/pyros.git PYROS
101 1 Etienne Pallier
</pre>
102 86 Etienne Pallier
103 86 Etienne Pallier
_(or also : git clone git@gitlab.irap.omp.eu:epallier/pyros.git PYROS)_
104 5 Etienne Pallier
105 126 Etienne Pallier
If you ever get this error message :
106 126 Etienne Pallier
<pre>
107 126 Etienne Pallier
fatal: unable to access 'https://gitlab.irap.omp.eu/epallier/pyros.git/': Peer's certificate issuer has been marked as not trusted by the user.
108 126 Etienne Pallier
</pre>
109 126 Etienne Pallier
110 126 Etienne Pallier
Then, type this command (and then run again the git clone command):
111 126 Etienne Pallier
<pre>
112 126 Etienne Pallier
$ git config --global http.sslVerify false
113 126 Etienne Pallier
</pre>
114 126 Etienne Pallier
115 126 Etienne Pallier
(Also, the first time you get the project, it will ask you for a login and password)
116 124 Etienne Pallier
117 5 Etienne Pallier
This creates a PYROS/ folder containing the project (with a .git/ subfolder for synchronization with the git repository)
118 1 Etienne Pallier
119 1 Etienne Pallier
120 122 Etienne Pallier
h4. (Windows only) : Get git for Windows
121 122 Etienne Pallier
122 122 Etienne Pallier
 * Download git at https://git-scm.com/download/win
123 121 Paul Carensac
 * Run setup (keep default configurations)
124 121 Paul Carensac
 * Once installed, open cmd
125 121 Paul Carensac
<pre>
126 121 Paul Carensac
$ git config --global http.sslVerify false
127 1 Etienne Pallier
</pre>
128 121 Paul Carensac
129 168 Etienne Pallier
You can now use your git from the cmd or the graphic client !
130 168 Etienne Pallier
131 168 Etienne Pallier
132 169 Etienne Pallier
133 169 Etienne Pallier
134 169 Etienne Pallier
---
135 169 Etienne Pallier
136 169 Etienne Pallier
---
137 169 Etienne Pallier
138 166 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}III - PREREQUISITES%
139 1 Etienne Pallier
140 167 Etienne Pallier
Pyros needs 2 prerequisites : a Database server (mysql or sqlite), and Python 3
141 9 Etienne Pallier
142 9 Etienne Pallier
---
143 1 Etienne Pallier
144 38 Etienne Pallier
h3. Install a database server (only if necessary)
145 38 Etienne Pallier
146 89 Etienne Pallier
_If the MySql database server is already installed on your computer, skip this section_
147 72 Etienne Pallier
148 50 Etienne Pallier
By default, Pyros uses Mysql, but this implies that you have to install the Mysql database server...
149 1 Etienne Pallier
150 40 Etienne Pallier
Thus, to make things easier, avoid Mysql installation by using Sqlite instead as the database server (which will need no installation at all) :
151 40 Etienne Pallier
152 133 Etienne Pallier
=> *For this, just edit the file PYROS/src/pyros/settings.py and set MYSQL variable to False, and that's it. You can go to next section*
153 40 Etienne Pallier
154 44 Etienne Pallier
Now, if you really want to use Mysql (which is the default), you will need to install it (only if not already installed), so keep reading.
155 40 Etienne Pallier
156 44 Etienne Pallier
_(Skip this if you are using Sqlite instead of MySql)_
157 9 Etienne Pallier
158 9 Etienne Pallier
 * Linux Ubuntu
159 9 Etienne Pallier
<pre>
160 149 Etienne Pallier
First, update your system:
161 149 Etienne Pallier
$ sudo apt-get update
162 149 Etienne Pallier
163 9 Etienne Pallier
$ sudo apt-get install mysql-server
164 9 Etienne Pallier
$ sudo apt-get install mysql-client
165 9 Etienne Pallier
166 147 Etienne Pallier
$ sudo apt-get install libmysqlclient-dev
167 147 Etienne Pallier
(needed for python package mysqlclient)
168 9 Etienne Pallier
</pre>
169 9 Etienne Pallier
170 141 Etienne Pallier
 * Linux CentOS : cf https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp#-installing-mysql-
171 138 Etienne Pallier
<pre>
172 149 Etienne Pallier
First, update your system:
173 138 Etienne Pallier
$ sudo yum update yum
174 138 Etienne Pallier
$ sudo yum update kernel
175 138 Etienne Pallier
$ sudo yum update
176 138 Etienne Pallier
177 150 Etienne Pallier
$ sudo yum install mariadb-server 
178 150 Etienne Pallier
$ sudo yum install mariadb
179 144 Etienne Pallier
180 142 Etienne Pallier
$ sudo yum install mariadb-devel
181 144 Etienne Pallier
(needed for python package mysqlclient)
182 140 Etienne Pallier
183 140 Etienne Pallier
$ sudo systemctl start mariadb.service
184 140 Etienne Pallier
185 140 Etienne Pallier
$ sudo systemctl enable mariadb.service
186 140 Etienne Pallier
=> Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
187 142 Etienne Pallier
188 142 Etienne Pallier
$ sudo mysql_secure_installation
189 9 Etienne Pallier
</pre>
190 9 Etienne Pallier
191 9 Etienne Pallier
 * Mac OS X
192 9 Etienne Pallier
Install XAMPP
193 51 Etienne Pallier
(but you could also use the pre-installed Mac OS MySql, or install MySql from macport)
194 9 Etienne Pallier
<pre>
195 9 Etienne Pallier
TODO:
196 9 Etienne Pallier
</pre>
197 9 Etienne Pallier
198 54 Etienne Pallier
 * Windows (tested with Windows 7)
199 9 Etienne Pallier
200 9 Etienne Pallier
<pre>
201 9 Etienne Pallier
Download and install the newest version on https://dev.mysql.com/downloads/installer/
202 9 Etienne Pallier
203 9 Etienne Pallier
Once installed, launch MySQL Installer. Clic on 'Add...' on the right.
204 9 Etienne Pallier
In MySQLServers section, choose the newest, then clic on next.
205 9 Etienne Pallier
Install and configure the server (just follow the installation guide).
206 9 Etienne Pallier
207 9 Etienne Pallier
Then launch mysql (via the Windows menu).
208 9 Etienne Pallier
</pre>
209 9 Etienne Pallier
210 9 Etienne Pallier
211 9 Etienne Pallier
---
212 9 Etienne Pallier
213 132 Etienne Pallier
h3. Install Python3 + pip + virtualenv (only if necessary)
214 73 Etienne Pallier
215 73 Etienne Pallier
_If Python 3 is already installed on your computer, skip this section_
216 9 Etienne Pallier
217 9 Etienne Pallier
218 129 Etienne Pallier
 * Linux (CentOS 7.1, main target): (python35 not yet available as rpm)
219 1 Etienne Pallier
<pre>
220 129 Etienne Pallier
$ sudo yum update yum
221 137 Etienne Pallier
$ sudo yum update kernel
222 129 Etienne Pallier
$ sudo yum update
223 129 Etienne Pallier
224 1 Etienne Pallier
$ sudo yum install python34
225 129 Etienne Pallier
$ python3.4 -V
226 129 Etienne Pallier
Python 3.4.3
227 129 Etienne Pallier
228 143 Etienne Pallier
$ sudo yum install python34-devel
229 145 Etienne Pallier
(needed for python package mysqlclient)
230 143 Etienne Pallier
231 129 Etienne Pallier
$ sudo yum update python-setuptools
232 129 Etienne Pallier
$ easy_install --version
233 129 Etienne Pallier
setuptools 0.9.8
234 129 Etienne Pallier
$ sudo easy_install pip
235 129 Etienne Pallier
$ pip --version
236 129 Etienne Pallier
pip 8.1.1 from /usr/lib/python2.7/site-packages/pip-8.1.1-py2.7.egg (python 2.7)
237 129 Etienne Pallier
238 129 Etienne Pallier
239 129 Etienne Pallier
$ sudo pip install virtualenv
240 129 Etienne Pallier
$ virtualenv --version
241 129 Etienne Pallier
15.0.1
242 127 Etienne Pallier
</pre>
243 127 Etienne Pallier
244 127 Etienne Pallier
 * Linux (Ubuntu) :
245 127 Etienne Pallier
<pre>
246 127 Etienne Pallier
$ sudo add-apt-repository ppa:fkrull/deadsnakes
247 127 Etienne Pallier
$ sudo apt-get update
248 127 Etienne Pallier
$ sudo apt-get install python3.5
249 147 Etienne Pallier
250 147 Etienne Pallier
$ sudo apt-get install python3.5-dev
251 147 Etienne Pallier
(needed for python package mysqlclient)
252 147 Etienne Pallier
253 127 Etienne Pallier
$ sudo pip install virtualenv
254 127 Etienne Pallier
</pre>
255 127 Etienne Pallier
256 127 Etienne Pallier
257 52 Etienne Pallier
 * Mac OS X :
258 1 Etienne Pallier
259 53 Etienne Pallier
  * From binary (Mac OS native application)
260 9 Etienne Pallier
(TODO:)
261 9 Etienne Pallier
262 9 Etienne Pallier
  * From MacPort
263 9 Etienne Pallier
264 9 Etienne Pallier
   * a) install macport
265 9 Etienne Pallier
(TODO:)
266 9 Etienne Pallier
267 9 Etienne Pallier
   * b) install the "port" python35
268 9 Etienne Pallier
<pre>
269 9 Etienne Pallier
$ sudo port install python35
270 9 Etienne Pallier
</pre>
271 9 Etienne Pallier
272 9 Etienne Pallier
273 55 Etienne Pallier
 * Windows (tested with Windows 7) :
274 56 Etienne Pallier
(TODO: test with Windows 10)
275 9 Etienne Pallier
<pre>
276 9 Etienne Pallier
Go to https://www.python.org/downloads/windows/ , choose the wanted version
277 9 Etienne Pallier
On the wanted version’s page, download Windows x86 executable installer
278 9 Etienne Pallier
279 9 Etienne Pallier
Run the executable
280 9 Etienne Pallier
    * On the first page, check "Add python3.5 to PATH"
281 9 Etienne Pallier
    * Choose "Install now" option
282 9 Etienne Pallier
283 9 Etienne Pallier
Open cmd (windows + R, cmd) :
284 9 Etienne Pallier
 $ python -m pip install --upgrade pip
285 9 Etienne Pallier
 $ pip install virtualenv
286 9 Etienne Pallier
</pre>
287 9 Etienne Pallier
288 1 Etienne Pallier
---
289 1 Etienne Pallier
290 170 Etienne Pallier
---
291 170 Etienne Pallier
292 170 Etienne Pallier
293 166 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}IV - INSTALLATION OF NEEDED PYTHON DEPENDENCIES%
294 166 Etienne Pallier
295 166 Etienne Pallier
Install the needed Python dependencies and the database (within a Python virtual environment)
296 98 Etienne Pallier
297 136 Etienne Pallier
Go into the PYROS/install/ folder and Run the install_requirements.sh script.
298 1 Etienne Pallier
299 136 Etienne Pallier
(You will be prompted to enter a username, an email, and a password for the superuser)
300 136 Etienne Pallier
301 1 Etienne Pallier
* Mac and Linux:
302 110 Paul Carensac
<pre>
303 110 Paul Carensac
./install_requirements.sh
304 1 Etienne Pallier
</pre>
305 107 Etienne Pallier
306 134 Etienne Pallier
* Windows:
307 135 Etienne Pallier
<pre>
308 134 Etienne Pallier
install_requirements_windows.bat
309 107 Etienne Pallier
</pre>
310 98 Etienne Pallier
311 98 Etienne Pallier
_If something goes wrong, install manually each package (see section "MANUAL INSTALLATION OF PYTHON PACKAGES, ONE BY ONE")_
312 98 Etienne Pallier
313 9 Etienne Pallier
---
314 9 Etienne Pallier
315 9 Etienne Pallier
h3. (Eclipse only) Set the Python3 virtual environment as the project interpreter
316 9 Etienne Pallier
317 65 Etienne Pallier
See below, in section "NOTES FOR ECLIPSE USERS"
318 9 Etienne Pallier
319 1 Etienne Pallier
---
320 1 Etienne Pallier
321 170 Etienne Pallier
---
322 170 Etienne Pallier
323 17 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}IV - TEST%
324 17 Etienne Pallier
325 108 Etienne Pallier
326 90 Etienne Pallier
(Tests are classes declared in all apps' test.py file. The test classes inherit from django.test.TestCase)
327 17 Etienne Pallier
328 17 Etienne Pallier
You can run the tests suite, just to be sure that the software is well installed.
329 17 Etienne Pallier
330 19 Etienne Pallier
h3. From Terminal
331 19 Etienne Pallier
332 19 Etienne Pallier
333 1 Etienne Pallier
<pre>
334 1 Etienne Pallier
335 94 Etienne Pallier
$ cd PYROS/
336 20 Etienne Pallier
337 159 Paul Carensac
$ ./pyrosrun test
338 94 Etienne Pallier
Ran 5 tests in 0.093s
339 21 Etienne Pallier
OK
340 17 Etienne Pallier
</pre>
341 19 Etienne Pallier
342 160 Paul Carensac
h3. From Eclipse
343 1 Etienne Pallier
344 77 Etienne Pallier
See below, in section "NOTES FOR ECLIPSE USERS"
345 25 Paul Carensac
346 25 Paul Carensac
347 160 Paul Carensac
h3. Custom commands
348 27 Paul Carensac
349 25 Paul Carensac
$ [./manage.py] test app.tests                           # Run tests for the application 'app'
350 25 Paul Carensac
$ [./manage.py] test app.tests.ModelTests                # Run test methods declared in the class app.tests.ModelTests
351 25 Paul Carensac
$ [./manage.py] test app.tests.ModelTests.test_method    # Only run the method test_method declared in app.tests.ModelTests
352 33 Etienne Pallier
353 33 Etienne Pallier
354 1 Etienne Pallier
---
355 1 Etienne Pallier
356 170 Etienne Pallier
---
357 170 Etienne Pallier
358 92 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}V - RUN%
359 75 Etienne Pallier
360 109 Etienne Pallier
361 75 Etienne Pallier
* From the terminal
362 75 Etienne Pallier
363 75 Etienne Pallier
<pre>
364 75 Etienne Pallier
365 95 Etienne Pallier
$ cd PYROS/
366 1 Etienne Pallier
367 158 Paul Carensac
$ ./pyrosrun server
368 93 Paul Carensac
</pre>
369 75 Etienne Pallier
370 158 Paul Carensac
Now, go to "http://localhost:8000/admin" in your browser
371 91 Etienne Pallier
372 158 Paul Carensac
(and login as "pyros" with the password 'DjangoPyros')
373 105 Etienne Pallier
374 91 Etienne Pallier
(Ctrl-c to stop)
375 91 Etienne Pallier
376 91 Etienne Pallier
377 75 Etienne Pallier
378 106 Etienne Pallier
* From Eclipse : see below, in section "NOTES FOR ECLIPSE USERS"
379 75 Etienne Pallier
380 75 Etienne Pallier
381 1 Etienne Pallier
---
382 1 Etienne Pallier
383 170 Etienne Pallier
---
384 170 Etienne Pallier
385 33 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}NOTES FOR ECLIPSE USERS%
386 35 Etienne Pallier
387 35 Etienne Pallier
0) Install Eclipse (if necessary)
388 35 Etienne Pallier
389 35 Etienne Pallier
Get the Eclipse version for Php
390 35 Etienne Pallier
391 35 Etienne Pallier
Install the plug-in pydev (via install new software, add http://pydev.org/updates)
392 35 Etienne Pallier
393 35 Etienne Pallier
Install the django template editor (via install new software, add http://eclipse.kacprzak.org/updates)
394 35 Etienne Pallier
395 35 Etienne Pallier
1) Deactivate CA certificate verification
396 35 Etienne Pallier
397 35 Etienne Pallier
Window -> Preferences -> Team -> git -> configuration -> Add entry
398 35 Etienne Pallier
399 35 Etienne Pallier
Key = http.sslVerify
400 35 Etienne Pallier
Value = false
401 35 Etienne Pallier
402 35 Etienne Pallier
2) Fetch the project
403 35 Etienne Pallier
404 35 Etienne Pallier
File/Import project from git
405 35 Etienne Pallier
406 35 Etienne Pallier
Select repository source: Clone URI: https://gitlab.irap.omp.eu/epallier/pyros.git
407 35 Etienne Pallier
408 35 Etienne Pallier
Directory: 
409 35 Etienne Pallier
par défaut, il propose : /Users/epallier/git/pyros
410 35 Etienne Pallier
mais on peut le mettre ailleurs (c'est ce que j'ai fait)
411 35 Etienne Pallier
412 35 Etienne Pallier
initial branch: master
413 35 Etienne Pallier
remote name: origin
414 35 Etienne Pallier
415 35 Etienne Pallier
Import as general project
416 35 Etienne Pallier
417 35 Etienne Pallier
Project name: PYROS
418 35 Etienne Pallier
419 35 Etienne Pallier
420 35 Etienne Pallier
3) Configure the project
421 35 Etienne Pallier
422 35 Etienne Pallier
The project is created. Now, you have to set it as a «PyDev » and a « Django » project.
423 35 Etienne Pallier
424 35 Etienne Pallier
clic droit sur le projet / PyDev / set as a PyDev project
425 35 Etienne Pallier
426 35 Etienne Pallier
clic droit sur le projet / PyDev / set as a Django project
427 35 Etienne Pallier
428 35 Etienne Pallier
clic droit sur le projet : on doit maintenant avoir un sous-menu Django
429 35 Etienne Pallier
430 35 Etienne Pallier
clic droit sur le dossier src / PyDev / set as source folder (add to PYTHONPATH)
431 35 Etienne Pallier
432 35 Etienne Pallier
clic droit sur projet / Properties / Pydev-Django :
433 35 Etienne Pallier
  - Django manage.py : src/manage.py
434 35 Etienne Pallier
  - Django settings module : pyros.settings
435 35 Etienne Pallier
436 35 Etienne Pallier
437 35 Etienne Pallier
4) Set Code style
438 35 Etienne Pallier
439 35 Etienne Pallier
Window/Preferences : Pydev / Editor
440 35 Etienne Pallier
- Auto Imports : uncheck « Do auto import »
441 35 Etienne Pallier
- Code style:
442 35 Etienne Pallier
	- Locals … : camelCase
443 35 Etienne Pallier
	- Methods : camelCase() with first lower
444 35 Etienne Pallier
- Code style / Code Formatter: activer « use autopep8.py for code formatting »
445 35 Etienne Pallier
- Tabs : Tab length : 4
446 35 Etienne Pallier
447 67 Etienne Pallier
5) Now, once the Python3 virtual environment is installed (see above),
448 66 Etienne Pallier
set it in Eclipse as the project interpreter:
449 66 Etienne Pallier
450 68 Etienne Pallier
Right clic on the project / Properties / PyDev - Interpreter/Grammar :
451 66 Etienne Pallier
Grammar version : 3
452 66 Etienne Pallier
453 66 Etienne Pallier
Interpreter : click on « click here to configure an interpreter not listed »
454 66 Etienne Pallier
455 66 Etienne Pallier
click on « New... » :
456 66 Etienne Pallier
- Interpreter name : venv_py35_pyros
457 66 Etienne Pallier
- Interpreter executable : click on « Browse »
458 66 Etienne Pallier
	Select your virtualenv python35 executable (private/venv_py35_pyros/bin/python3.5)
459 66 Etienne Pallier
	click OK
460 66 Etienne Pallier
461 66 Etienne Pallier
*Now, a last thing to do so that Pydev finds Django:*
462 66 Etienne Pallier
463 66 Etienne Pallier
In the Python interpreters list, select your virtual env (venv_py35_pyros)
464 66 Etienne Pallier
465 66 Etienne Pallier
Click on the tab "Libraries"
466 66 Etienne Pallier
467 66 Etienne Pallier
clic on 'New folder', then select your virtualenv's lib/python3.5/site-packages folder
468 66 Etienne Pallier
469 66 Etienne Pallier
OK
470 66 Etienne Pallier
471 66 Etienne Pallier
Interpreter: select now venv_py35_pyros from the list
472 66 Etienne Pallier
473 66 Etienne Pallier
OK
474 62 Etienne Pallier
475 78 Etienne Pallier
6) Test
476 1 Etienne Pallier
477 78 Etienne Pallier
* Right-clic on the project / Django / Run Django tests
478 78 Etienne Pallier
479 78 Etienne Pallier
* Right-clic on the project / Django / Custom command / ...
480 78 Etienne Pallier
481 78 Etienne Pallier
482 78 Etienne Pallier
7) Run
483 70 Etienne Pallier
484 70 Etienne Pallier
Right clic on project -> Django/Custom command/runserver
485 70 Etienne Pallier
486 70 Etienne Pallier
Error on Ubuntu :
487 70 Etienne Pallier
488 70 Etienne Pallier
<pre>
489 70 Etienne Pallier
490 70 Etienne Pallier
Traceback (most recent call last):
491 70 Etienne Pallier
  File "/home/carens_p/git/pyros/src/manage.py", line 8, in <module>
492 70 Etienne Pallier
    from django.core.management import execute_from_command_line
493 70 Etienne Pallier
ImportError: No module named 'django'
494 70 Etienne Pallier
495 70 Etienne Pallier
</pre>
496 70 Etienne Pallier
497 70 Etienne Pallier
Project -> Properties -> Pydev interpreter -> Clic here to configure an interpreter not listed
498 70 Etienne Pallier
499 70 Etienne Pallier
select venv_py35_pyros
500 70 Etienne Pallier
501 70 Etienne Pallier
In Libraries, clic on 'New folder', then select your virtualenv's lib/python3.5/site-packages folder.
502 70 Etienne Pallier
503 70 Etienne Pallier
OK -> re-select venv_py35_pyros in 'Interpreter' dropdown menu
504 70 Etienne Pallier
505 70 Etienne Pallier
Then right clic on project -> Django/Custom command/runserver
506 70 Etienne Pallier
507 70 Etienne Pallier
check http://localhost:8000/
508 70 Etienne Pallier
509 70 Etienne Pallier
510 62 Etienne Pallier
---
511 62 Etienne Pallier
512 62 Etienne Pallier
---
513 62 Etienne Pallier
514 81 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}MANUAL INSTALLATION OF PYTHON PACKAGES ONE BY ONE%
515 81 Etienne Pallier
516 172 Etienne Pallier
*Follow these steps only if the previous guided and nearly automatic installation did not work for you*
517 100 Etienne Pallier
518 172 Etienne Pallier
519 100 Etienne Pallier
h3. Create a Python3 virtual environment dedicated to the project (inside the project folder)
520 100 Etienne Pallier
521 100 Etienne Pallier
<pre>
522 100 Etienne Pallier
523 100 Etienne Pallier
$ mkdir private/
524 100 Etienne Pallier
525 100 Etienne Pallier
$ cd private/
526 100 Etienne Pallier
527 100 Etienne Pallier
$ which python3.5 ("where python" for windows)
528 100 Etienne Pallier
/opt/local/bin/python3.5
529 100 Etienne Pallier
530 100 Etienne Pallier
$ virtualenv venv_py35_pyros -p /opt/local/bin/python3.5
531 100 Etienne Pallier
=> creates a venv_py35_pyros/ folder inside PYROS/private/
532 100 Etienne Pallier
533 100 Etienne Pallier
</pre>
534 100 Etienne Pallier
535 100 Etienne Pallier
536 100 Etienne Pallier
---
537 100 Etienne Pallier
538 100 Etienne Pallier
h3. Activate the python virtual environment (from inside the project)
539 100 Etienne Pallier
540 100 Etienne Pallier
<pre>
541 100 Etienne Pallier
542 100 Etienne Pallier
$ pwd
543 100 Etienne Pallier
.../PYROS/private
544 100 Etienne Pallier
545 100 Etienne Pallier
$ source ./venv_py35_pyros/bin/activate (venv_py35_pyros/Scripts/activate on Windows)
546 100 Etienne Pallier
547 100 Etienne Pallier
</pre>
548 100 Etienne Pallier
549 100 Etienne Pallier
---
550 100 Etienne Pallier
551 100 Etienne Pallier
h3. Install needed python packages
552 100 Etienne Pallier
553 81 Etienne Pallier
Check that the virtual environment is activated
554 81 Etienne Pallier
<pre>
555 81 Etienne Pallier
$ python -V
556 81 Etienne Pallier
Python 3...
557 81 Etienne Pallier
558 81 Etienne Pallier
$ which pip
559 81 Etienne Pallier
.../PYROS/venv_py35_pyros/bin/pip
560 81 Etienne Pallier
</pre>
561 81 Etienne Pallier
562 81 Etienne Pallier
563 81 Etienne Pallier
Upgrade pip to last version available:
564 81 Etienne Pallier
<pre>
565 81 Etienne Pallier
$ pip install --upgrade pip
566 81 Etienne Pallier
Collecting pip
567 81 Etienne Pallier
  Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB)
568 81 Etienne Pallier
Installing collected packages: pip
569 81 Etienne Pallier
  Found existing installation: pip 7.1.2
570 81 Etienne Pallier
    Uninstalling pip-7.1.2:
571 81 Etienne Pallier
      Successfully uninstalled pip-7.1.2
572 81 Etienne Pallier
Successfully installed pip-8.1.1
573 81 Etienne Pallier
574 81 Etienne Pallier
Upgrade wheel to last version available:
575 81 Etienne Pallier
$ pip install --upgrade wheel
576 81 Etienne Pallier
Collecting wheel
577 81 Etienne Pallier
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
578 81 Etienne Pallier
Installing collected packages: wheel
579 81 Etienne Pallier
  Found existing installation: wheel 0.24.0
580 81 Etienne Pallier
    Uninstalling wheel-0.24.0:
581 81 Etienne Pallier
      Successfully uninstalled wheel-0.24.0
582 81 Etienne Pallier
Successfully installed wheel-0.29.0
583 81 Etienne Pallier
584 81 Etienne Pallier
</pre>
585 81 Etienne Pallier
586 81 Etienne Pallier
Go into the install/ folder:
587 81 Etienne Pallier
<pre>
588 81 Etienne Pallier
$ cd .../PYROS/install/
589 81 Etienne Pallier
</pre>
590 81 Etienne Pallier
591 84 Etienne Pallier
Install all the needed python packages at once:
592 85 Etienne Pallier
<pre>
593 1 Etienne Pallier
$ pip install -r REQUIREMENTS.txt
594 85 Etienne Pallier
</pre>
595 84 Etienne Pallier
596 84 Etienne Pallier
If something goes wrong, install them one by one:
597 62 Etienne Pallier
598 62 Etienne Pallier
  * *Install Django* :
599 62 Etienne Pallier
<pre>
600 62 Etienne Pallier
$ pip install django
601 62 Etienne Pallier
Collecting django
602 62 Etienne Pallier
  Downloading Django-1.9.4-py2.py3-none-any.whl (6.6MB)
603 62 Etienne Pallier
Installing collected packages: django
604 62 Etienne Pallier
Successfully installed django-1.9.4
605 62 Etienne Pallier
606 62 Etienne Pallier
$ pip install django-admin-tools
607 62 Etienne Pallier
Collecting django-admin-tools
608 62 Etienne Pallier
  Downloading django_admin_tools-0.7.2-py2.py3-none-any.whl (289kB)
609 62 Etienne Pallier
Installing collected packages: django-admin-tools
610 62 Etienne Pallier
Successfully installed django-admin-tools-0.7.2
611 62 Etienne Pallier
612 62 Etienne Pallier
$ pip install django-debug-toolbar
613 62 Etienne Pallier
Collecting django-debug-toolbar
614 62 Etienne Pallier
  Downloading django_debug_toolbar-1.4-py2.py3-none-any.whl (212kB)
615 62 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)
616 62 Etienne Pallier
Collecting sqlparse (from django-debug-toolbar)
617 62 Etienne Pallier
  Downloading sqlparse-0.1.19.tar.gz (58kB)
618 62 Etienne Pallier
Building wheels for collected packages: sqlparse
619 62 Etienne Pallier
  Running setup.py bdist_wheel for sqlparse ... done
620 62 Etienne Pallier
  Stored in directory: /Users/epallier/Library/Caches/pip/wheels/7b/d4/72/6011bb100dd5fc213164e4bbee13d4e03261dd54ce6a5de6b8
621 62 Etienne Pallier
Successfully built sqlparse
622 62 Etienne Pallier
Installing collected packages: sqlparse, django-debug-toolbar
623 62 Etienne Pallier
Successfully installed django-debug-toolbar-1.4 sqlparse-0.1.19
624 62 Etienne Pallier
625 62 Etienne Pallier
$ pip install django-extensions
626 62 Etienne Pallier
Collecting django-extensions
627 62 Etienne Pallier
  Downloading django_extensions-1.6.1-py2.py3-none-any.whl (202kB)
628 62 Etienne Pallier
Collecting six>=1.2 (from django-extensions)
629 62 Etienne Pallier
  Downloading six-1.10.0-py2.py3-none-any.whl
630 62 Etienne Pallier
Installing collected packages: six, django-extensions
631 62 Etienne Pallier
Successfully installed django-extensions-1.6.1 six-1.10.0
632 62 Etienne Pallier
633 62 Etienne Pallier
$ pip install django-suit
634 62 Etienne Pallier
Collecting django-suit
635 62 Etienne Pallier
  Downloading django-suit-0.2.18.tar.gz (587kB)
636 62 Etienne Pallier
Building wheels for collected packages: django-suit
637 62 Etienne Pallier
  Running setup.py bdist_wheel for django-suit ... done
638 62 Etienne Pallier
  Stored in directory: /Users/epallier/Library/Caches/pip/wheels/12/8b/9a/e02ab0ad9229881638aa040d47d77c8f562999533811927d41
639 62 Etienne Pallier
Successfully built django-suit
640 62 Etienne Pallier
Installing collected packages: django-suit
641 62 Etienne Pallier
Successfully installed django-suit-0.2.18
642 62 Etienne Pallier
643 62 Etienne Pallier
</pre>
644 62 Etienne Pallier
645 62 Etienne Pallier
  * *Install the django boostrap css package* :
646 62 Etienne Pallier
<pre>
647 62 Etienne Pallier
$ pip install django-bootstrap3
648 62 Etienne Pallier
</pre>
649 62 Etienne Pallier
(==> 'bootstrap3' is then to be added as an application in settings.py -> INSTALLED_APPS)
650 62 Etienne Pallier
651 62 Etienne Pallier
  * *Install the web application server gunicorn (will be used in production instead of the dev django web server)* :
652 62 Etienne Pallier
<pre>
653 62 Etienne Pallier
$ pip install gunicorn
654 62 Etienne Pallier
Collecting gunicorn
655 62 Etienne Pallier
  Downloading gunicorn-19.4.5-py2.py3-none-any.whl (112kB)
656 62 Etienne Pallier
Installing collected packages: gunicorn
657 62 Etienne Pallier
Successfully installed gunicorn-19.4.5
658 62 Etienne Pallier
</pre>
659 62 Etienne Pallier
660 62 Etienne Pallier
  * *Install the python mysql client* (not needed if you want to use sqlite):
661 62 Etienne Pallier
<pre>
662 62 Etienne Pallier
$ pip install mysqlclient
663 62 Etienne Pallier
...
664 62 Etienne Pallier
</pre>
665 62 Etienne Pallier
666 146 Etienne Pallier
   * => If issue under Mac OS X:
667 62 Etienne Pallier
<pre>
668 62 Etienne Pallier
$ pip install mysqlclient
669 62 Etienne Pallier
Collecting mysqlclient
670 62 Etienne Pallier
  Downloading mysqlclient-1.3.7.tar.gz (79kB)
671 62 Etienne Pallier
Building wheels for collected packages: mysqlclient
672 62 Etienne Pallier
  Running setup.py bdist_wheel for mysqlclient ... error
673 62 Etienne Pallier
674 62 Etienne Pallier
  ----------------------------------------
675 62 Etienne Pallier
  Failed building wheel for mysqlclient
676 62 Etienne Pallier
  Running setup.py clean for mysqlclient
677 62 Etienne Pallier
Failed to build mysqlclient
678 62 Etienne Pallier
Installing collected packages: mysqlclient
679 62 Etienne Pallier
  Running setup.py install for mysqlclient ... done
680 62 Etienne Pallier
Successfully installed mysqlclient-1.3.7
681 62 Etienne Pallier
682 62 Etienne Pallier
BOUH !!!
683 1 Etienne Pallier
684 152 Etienne Pallier
=> Need to upgrade wheel:
685 146 Etienne Pallier
686 62 Etienne Pallier
$ pip install --upgrade wheel
687 62 Etienne Pallier
Collecting wheel
688 62 Etienne Pallier
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
689 62 Etienne Pallier
Installing collected packages: wheel
690 62 Etienne Pallier
  Found existing installation: wheel 0.24.0
691 62 Etienne Pallier
    Uninstalling wheel-0.24.0:
692 62 Etienne Pallier
      Successfully uninstalled wheel-0.24.0
693 62 Etienne Pallier
Successfully installed wheel-0.29.0
694 62 Etienne Pallier
695 153 Etienne Pallier
YES !!!
696 1 Etienne Pallier
697 154 Etienne Pallier
Only if necessary, you can reinstall mysqlclient:
698 153 Etienne Pallier
$ pip uninstall mysqlclient
699 62 Etienne Pallier
$ pip install mysqlclient
700 62 Etienne Pallier
Collecting mysqlclient
701 62 Etienne Pallier
  Using cached mysqlclient-1.3.7.tar.gz
702 62 Etienne Pallier
Building wheels for collected packages: mysqlclient
703 62 Etienne Pallier
  Running setup.py bdist_wheel for mysqlclient ... done
704 62 Etienne Pallier
  Stored in directory: /Users/epallier/Library/Caches/pip/wheels/9b/06/50/d11418c26cf8f2156b13d4363b5afde8e7e75ebb8540d0228d
705 62 Etienne Pallier
Successfully built mysqlclient
706 62 Etienne Pallier
Installing collected packages: mysqlclient
707 62 Etienne Pallier
Successfully installed mysqlclient-1.3.7
708 62 Etienne Pallier
709 1 Etienne Pallier
</pre>
710 62 Etienne Pallier
711 146 Etienne Pallier
   * => If issue under Windows
712 62 Etienne Pallier
<pre>
713 62 Etienne Pallier
Same message as the issue for Mac.
714 146 Etienne Pallier
715 152 Etienne Pallier
=> Need to upgrade wheel:
716 62 Etienne Pallier
717 62 Etienne Pallier
Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient to download the newest mysqlclient wheel
718 62 Etienne Pallier
719 62 Etienne Pallier
$ pip install path\to\mysqlclient\wheel
720 62 Etienne Pallier
721 154 Etienne Pallier
(No need to redo "pip install mysqlclient")
722 62 Etienne Pallier
</pre>
723 163 Paul Carensac
724 163 Paul Carensac
  * *Install the julian day converter* :
725 163 Paul Carensac
<pre>
726 163 Paul Carensac
$ pip install jdcal
727 163 Paul Carensac
</pre>
728 172 Etienne Pallier
729 172 Etienne Pallier
730 172 Etienne Pallier
h3. (Only if using Mysql) Create the database "pyros" and the pyros user
731 172 Etienne Pallier
732 172 Etienne Pallier
Only if you are using Mysql, you need to create an empty database "pyros"
733 172 Etienne Pallier
(which will be filled automatically by django)
734 172 Etienne Pallier
735 172 Etienne Pallier
<pre>
736 172 Etienne Pallier
$ mysql -u root -p
737 172 Etienne Pallier
(enter your root password)
738 172 Etienne Pallier
739 172 Etienne Pallier
$ mysql> create database if not exists pyros;
740 172 Etienne Pallier
</pre>
741 172 Etienne Pallier
742 172 Etienne Pallier
The user creation depends on your MySQL version :
743 172 Etienne Pallier
744 172 Etienne Pallier
 * 5.7 and above :
745 172 Etienne Pallier
<pre>
746 172 Etienne Pallier
$ mysql> DROP USER IF EXISTS pyros;
747 172 Etienne Pallier
$ mysql> CREATE USER 'pyros' IDENTIFIED BY 'DjangoPyros';
748 172 Etienne Pallier
$ mysql> GRANT ALL PRIVILEGES ON pyros.* TO pyros;
749 172 Etienne Pallier
</pre>
750 172 Etienne Pallier
751 172 Etienne Pallier
 * under 5.7 :
752 172 Etienne Pallier
<pre>
753 172 Etienne Pallier
$ mysql> GRANT USAGE ON *.* TO 'pyros';
754 172 Etienne Pallier
$ mysql> DROP USER 'pyros';
755 172 Etienne Pallier
$ mysql> CREATE USER 'pyros' IDENTIFIED BY 'DjangoPyros';
756 172 Etienne Pallier
$ mysql> GRANT ALL PRIVILEGES ON pyros.* TO pyros;
757 172 Etienne Pallier
</pre>
758 172 Etienne Pallier
759 172 Etienne Pallier
If none of these solution work, check on the internet to create a user named pyros with the password DjangoPyros.