Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
vms:python:dev [2017/04/13 23:42]
admin [Virtualenvwrapper]
vms:python:dev [2017/05/31 02:55] (current)
admin [Virtualenvwrapper]
Line 62: Line 62:
  
 Virtual Environments are used to isolate python versions and package dependencies for each specific project. Virtual Environments are used to isolate python versions and package dependencies for each specific project.
 +
 +We'll begin by creating specific users for python:
 +<​Code:​bash>​
 +> adduser py2
 +...
 +<​password>​
 +...
 +> adduser py3
 +...
 +<​password>​
 +...
 +
 +# To act as py2:
 +> su py2 
 +</​Code>​
  
 We'll install ''​virtualenv''​ for User only in order to allow coexistence of Python2 and Python3. As the virtualenv binary will bear the same name for 2 & 3, we'll move them on the go: We'll install ''​virtualenv''​ for User only in order to allow coexistence of Python2 and Python3. As the virtualenv binary will bear the same name for 2 & 3, we'll move them on the go:
Line 72: Line 87:
 > nano ~/.bashrc > nano ~/.bashrc
 ADD: ADD:
-Python ​virtualenv +USER INSTALLED BINARIES [virtualenv(wrapper)] 
-alias virtualenv2="~/.local/​lib/​python2.7/bin/virtualenv"​+export PATH=$PATH:~/​.local/​bin/​
  
 > source ~/.bashrc > source ~/.bashrc
-virtualenv2 ​--version+virtualenv ​--version
 15.1.0 15.1.0
 </​Code> ​ </​Code> ​
Line 115: Line 130:
  
 [[https://​virtualenvwrapper.readthedocs.io/​en/​latest/​]] [[https://​virtualenvwrapper.readthedocs.io/​en/​latest/​]]
 +
 +=== Installation & Configuration ===
  
 Install virtualenvwrapper for python3 for the user only: Install virtualenvwrapper for python3 for the user only:
Line 121: Line 138:
 > mv ~/​.local/​bin/​* ~/​.local/​lib/​python3.4/​bin/​ > mv ~/​.local/​bin/​* ~/​.local/​lib/​python3.4/​bin/​
 > rm ~/​.local/​bin > rm ~/​.local/​bin
-> mkdir projects+> mkdir -p projects/code
 > nano .bashrc > nano .bashrc
 ADD: ADD:
  
-VirtualenvWrapper+USER INSTALLED BINARIES [virtualenv(wrapper)] 
 +export PATH=~/​.local/​bin:​$PATH 
 + 
 +# VIRTUALENVWRAPPER
 export WORKON_HOME=$HOME/​.virtualenvs export WORKON_HOME=$HOME/​.virtualenvs
-export PROJECT_HOME=$HOME/​projects +export PROJECT_HOME=$HOME[/code] 
-export VIRTUALENVWRAPPER_PYTHON=/​usr/​bin/​python3 +export VIRTUALENVWRAPPER_PYTHON=/​usr/​bin/​python[2|3] 
-source ​$HOME/​.local/​lib/python3.4/​bin/​virtualenvwrapper.sh+export VIRTUALENVWRAPPER_VIRTUALENV=$HOME/​.local/​bin/​virtualenv 
 + 
 +source $HOME/.local/​bin/​virtualenvwrapper.sh
  
 > source .bashrc > source .bashrc
Line 136: Line 158:
 ... ...
 virtualenvwrapper.user_scripts creating /​home/​dev/​.virtualenvs/​get_env_details virtualenvwrapper.user_scripts creating /​home/​dev/​.virtualenvs/​get_env_details
 +
 +> mkvirtualenv temp
 +Using base prefix '/​usr'​
 +New python executable in /​home/​dev/​.virtualenvs/​temp/​bin/​python3
 +Also creating executable in /​home/​dev/​.virtualenvs/​temp/​bin/​python
 +Installing setuptools, pip, wheel...done.
 +...
 +...
 +(temp) >
 </​Code>​ </​Code>​
 +
 +=== Projects management ===
 +
 +[[http://​wiki.strategicz.com/​vhyper/​doku.php?​id=vms:​python:​django#​using_a_shared_folder_to_host_your_projects]]
 +<​Code>​
 +> VBoxManage setextradata <​VM_NAME>​ VBoxInternal2/​SharedFoldersEnableSymlinksCreate/<​SHARE_NAME>​ 1
 +</​Code>​
 +
 +<​Code>​
 +> nano /etc/fstab
 +
 +# automount shuup project space
 +<​SHARE_NAME> ​  /​home/​dev3/​projects ​  ​vboxsf ​  ​defaults,​uid=1001,​gid=1001,​dmode=775,​fmode=774,​umask=002 ​ 0   0
 +
 +</​Code>​
 +
 +[[https://​virtualenvwrapper.readthedocs.io/​en/​latest/​projects.html#​project-management]]
 +
 +===== Django =====
 +
 +[[http://​wiki.strategicz.com/​vhyper/​doku.php?​id=vms:​python:​django]]