1er commit

De la docs au format Mkdocs
This commit is contained in:
2018-09-16 14:48:15 +02:00
commit e82296ba06
140 changed files with 17082 additions and 0 deletions

View File

@@ -0,0 +1,99 @@
# Installer Django
[Django](https://docs.djangoproject.com/en/2.0/topics/install/#installing-distribution-package) est un framework Web Python.
#### Installer [mysqlclient](https://pypi.python.org/pypi/mysqlclient)
```bash
$ pip3 install mysqlclient
```
#### Installer Django
```bash
$ pip3 install Django
$ python3 -m django --version
2.0.2
```
[Django avec Apache et mod_wsgi](https://docs.djangoproject.com/fr/2.0/howto/deployment/wsgi/modwsgi/)
Se positionner en dehors de <u>Document root</u> (/Users/bruno) pour <u>démarrer un projet Django</u>:
```bash
~$ django-admin startproject mydjango
```
Installer [mod_wsgi](https://pypi.python.org/pypi/mod_wsgi) depuis <u>pip</u>:
```bash
$ APXS=/usr/local/bin/apxs pip3 install mod_wsgi
```
ou depuis Homebrew:
```bash
$ brew uninstall -vd mod_wsgi
$ brew install -vd mod_wsgi --with-homebrew-python
```
Lancer la commande `mod_wsgi-express module-config` pour connaitre les directives à ajouter à la configuration d'Apache (httpd.conf):
```bash
$ mod_wsgi-express module-config
LoadModule wsgi_module "/usr/local/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-darwin.so"
WSGIPythonHome "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6"
```
Une fois <u>https.conf</u> modifié, relancer Apache:
```bash
$ sudo apachectl -k restart -e Debug -E /dev/stdout
```
Une autre option est de copier le module <u>mod_wsgi</u> dans l'installation d'Apache avec la commande `mod_wsgi-expressinstall-module`
Se positionner dans le dossier <u>mydjango</u> pour démarrer le serveur:
```bash
$ python3 manage.py runserver
```
Pour changer le port (8000 par défaut)
```bash
$ python3 manage.py runserver 8001
```
Créer les tables dans la BDD.
```bash
$ python3 manage.py migrate
```
Création d'un utilisateur administrateur.
```bash
$ python manage.py createsuperuser
```
https://docs.djangoproject.com/fr/2.0/intro/tutorial03/#write-views-that-actually-do-something

View File

@@ -0,0 +1,10 @@
# WebServer
[Django](Django.md)
[pip](pip.md)
[python3](python3.md)

301
docs/macos/python/pip.md Normal file
View File

@@ -0,0 +1,301 @@
# Installer pip (python 2):
[:fa-link: https://apple.stackexchange.com/questions/209572/how-to-use-pip-after-the-os-x-el-capitan-upgrade](https://apple.stackexchange.com/questions/209572/how-to-use-pip-after-the-os-x-el-capitan-upgrade)
### Documentation pip:
[:fa-link: https://pip.pypa.io/en/stable/](https://pip.pypa.io/en/stable/)
### Installer pip:
```bash
$ sudo easy_install pip
```
Pour [Python 3](python3.md), **pip** est installé d'origine.
### Version courrante de pip:
```bash
$ pip --version
pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)
```
### Mettre à jour pip:
```bash
$ sudo pip install --upgrade pip
```
```bash
$ pip install --user --upgrade pip
```
!!! attention
Sur macOS, à cause de SIP (System Integrity Protection), l'installation se fait avec le mot-clé —user
### Cache:
Linux and Unix
```bash
~/.cache/pip # and it respects the XDG_CACHE_HOME directory.
```
OS X
```bash
~/Library/Caches/pip
```
Windows
```bash
%LocalAppData%\pip\Cache
```
pip peut installer en ignorant le cache:
```bash
pip --no-cache-dir install mkdocs
```
### Installer un module (mkdocs):
```bash
$ pip install --user mkdocs
```
Les modules sont ici:
`/Users/bruno/Library/Python/2.7/bin`
### Désinstaller un module:
```bash
$ pip uninstall <module>
```
### Installer une ancienne version d'un module:
```bash
$ pip3 show tornado
Name: tornado
Version: 5.0
.../...
$ pip3 install tornado==4.5.3
Collecting tornado==4.5.3
Installing collected packages: tornado
Found existing installation: tornado 5.0
Uninstalling tornado-5.0:
Successfully uninstalled tornado-5.0
Successfully installed tornado-4.5.3
$ pip3 install 'tornado>=4.1.0,<4.5.3'
```
### Informations sur un module:
```bash
$ pip show <module>
$ pip show mkdocs
Name: mkdocs
Version: 0.17.2
Summary: Project documentation with Markdown.
Home-page: http://www.mkdocs.org
Author: Tom Christie
Author-email: tom@tomchristie.com
License: BSD
Location: /Users/bruno/Library/Python/2.7/lib/python/site-packages
Requires: tornado, PyYAML, click, Markdown, Jinja2, livereload
```
### Liste des modules installés:
```bash
$ pip list --format=columns
Package Version
-------------------------------------- ---------
altgraph 0.10.2
backports-abc 0.5
bdist-mpkg 0.5.0
```
### Liste des modules mis-à-jour:
```bash
$ pip list --outdated --format=columns
Package Version Latest Type
-------------------------------------- -------- ------ -----
altgraph 0.10.2 0.15 wheel
macholib 1.5.1 1.9 wheel
matplotlib 1.3.1 2.1.1 wheel
```
```bash
$ pip3 list --outdated --format=freeze
packaging==16.8
Sphinx==1.7.0
```
```bash
$ pip3 list --outdated --format=columns
Package Version Latest Type
------
packaging 16.8 17.1 wheel
Sphinx 1.7.0 1.7.1 wheel
```
```bash
$ pip3 list --outdated --format=legacy
packaging (16.8) - Latest: 17.1 [wheel]
Sphinx (1.7.0) - Latest: 1.7.1 [wheel]
```
```bash
$ pip3 list --outdated --format=json
[{"name": "packaging", "version": "16.8", "latest_version": "17.1", "latest_filetype": "wheel"}, {"name": "Sphinx", "version": "1.7.0", "latest_version": "1.7.1", "latest_filetype": "wheel"}]
```
### Mettre à jour un module:
```bash
$ pip install --user --upgrade <module>
$ pip install --user --upgrade mkdocs-material
```
### Chercher un module:
```bash
$ pip search <module>
$ pip search markdown
aberdeen (0.4.0) - Conversion from markdown files to database entries to use as the backend of a blog
python-academicmarkdown (0.9.0) - A markdown preparser for academic writing
odoo8-addon-web-widget-text-markdown (8.0.1.0.0.99.dev7) - web_widget_text_markdown
lektor-markdown-admonition (0.1) - Adds basic admonition tag support to Markdown.
```
### Montrer les dépendances d'un module:
```bash
$ pip3 show mkdocs | grep Requires
Requires: tornado, Markdown, click, PyYAML, Jinja2, livereload
```
### Modules:
#### Yolk:
```bash
$ pip3 install yolk3k
```
Montrer les dépendances:
```bash
$ yolk -d mkdocs
mkdocs 0.17.3
PyYAML>=3.10
tornado<5.0,>=4.1
Jinja2>=2.7.1
click>=3.3
Markdown>=2.3.1
livereload>=2.5.1
```
Montrer les M-à-J disponibles:
```bash
$ yolk -U
tornado 4.5.3 (5.0)
```
Listes des modules installés:
```bash
$ yolk -l
Babel - 2.5.3 - active development (/usr/local/lib/python3.6/site packages)
Django - 2.0.3 - active development (/usr/local/lib/python3.6/site-packages)
```
#### pipdeptree:
Savoir quel module requiert tel module:
```bash
$ pipdeptree -r -p mkdocs
mkdocs==0.17.3
- mkdocs-material==2.7.0 [requires: mkdocs>=0.17.1]
```
Montrer les dépendances:
```bash
$ pipdeptree -p mkdocs
mkdocs==0.17.3
- click [required: >=3.3, installed: 6.7]
- Jinja2 [required: >=2.7.1, installed: 2.10]
- MarkupSafe [required: >=0.23, installed: 1.0]
- livereload [required: >=2.5.1, installed: 2.5.1]
- six [required: Any, installed: 1.11.0]
- tornado [required: Any, installed: 4.5.3]
- Markdown [required: >=2.3.1, installed: 2.6.11]
- PyYAML [required: >=3.10, installed: 3.12]
- tornado [required: <5.0,>=4.1, installed: 4.5.3]
```

View File

@@ -0,0 +1,120 @@
# Python 3
Python 3 peut s'installer avec Homebrew:
```bash
$ brew install python3
```
Les extensions Python 3 s'installent dans `/usr/local/lib/python3.6/site-packages/`
Pour lancer un script Python 3:
```bash
$ python3 script.py
```
Pour que python pointe sur Python 3 (homebrew), rajouter ceci à .bash_profile:
```bash
export PATH=/usr/local/opt/python/libexec/bin:$PATH
```
Pip est installé d'origine avec Python 3. On le lance avec la commande **pip3**:
```bash
$ pip3 list --outdated --format=columns
$ pip3 install mkdocs
```
Installation utilisateur:
```bash
$ python3 -m site --user-base
/Users/bruno/Library/Python/3.6
```
[Pipenv](https://docs.pipenv.org)
### Modules:
#### Mkdocs
Mkdocs si'installe dans `/usr/local/bin` :
```bash
bruno@silverbook:/usr/local/bin$ ./mkdocs --version
mkdocs, version 0.17.2
```
Par défaut, c'est **mkdocs** installé avec Python 2 (macOS) qui se lance.
Pour utiliser **mkdocs** installé pour Python 3 (Homebrew):
```bash
bruno@silverbook:~/project$ /usr/local/bin/mkdocs serve
```
Par comparaison, les extensions Python 2 s'installent dans `/Library/Python/2.7/site-packages/`
**Mkdocs** si'installe dans `~/Library/Python/2.7/bin` :
```bash
bruno@silverbook:~/Library/Python/2.7/bin$ ./mkdocs --version
mkdocs, version 0.17.2
```
#### Django
[Installer Django](Django.md)
#### Rechercher un module
[PyPI - the Python Package Index](https://pypi.python.org/pypi)
#### Problème à l'installation
Erreur lors de linstall de python3 avec Homebrew:
```bash
bruno@HackiMac:/usr/local/bin$ brew install python3
==> Downloading https://homebrew.bintray.com/bottles/python-3.7.0.high_sierra.bottle.3.tar.gz
Already downloaded: /Users/bruno/Library/Caches/Homebrew/downloads/d76c2354ae237f190a868bb74f28d606b88cce724222bafa114e91cd8a1462d5--python-3.7.0.high_sierra.bottle.3.tar.gz
==> Pouring python-3.7.0.high_sierra.bottle.3.tar.gz
Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
Permission denied @ dir_s_mkdir - /usr/local/Frameworks
Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks
```
Solution:
```bash
sudo mkdir /usr/local/Frameworks
sudo chown $(whoami):admin /usr/local/Frameworks
```