KEMBAR78
Python environments | KEY
Python
Environments!
     Epically winning at Python!

         Glen Zangirolami
         Twitter @glenbot
       http://theglenbot.com

Prepared for the 100th PyHou meetup.
Environments!
   Porque?
Environments!
       Porque?
Isolation - Python packages and even versions live in
their own little $HOME!
Environments!
       Porque?
Isolation - Python packages and even versions live in
their own little $HOME!

Permissions - Not everyone is 1337 and can be a sudoer.
Environments!
       Porque?
Isolation - Python packages and even versions live in
their own little $HOME!

Permissions - Not everyone is 1337 and can be a sudoer.

Organization - each project can maintain it’s own
requirements file of python packages and you don’t
have version overlap.
Environments!
       Porque?
Isolation - Python packages and even versions live in
their own little $HOME!

Permissions - Not everyone is 1337 and can be a sudoer.

Organization - each project can maintain it’s own
requirements file of python packages and you don’t
have version overlap.

Anti-globalization - installing stuff to the system
globally is generally not a good idea, unless it’s
something like PIP.
Ok fine. But how?
Ok fine. But how?
virtualenv

  http://pypi.python.org/pypi/virtualenv

virtualenvwrapper

  http://www.doughellmann.com/projects/
  virtualenvwrapper/

pythonbrew

  https://github.com/utahta/pythonbrew
virtualenv
virtualenv
$ easy_install pip
$ pip install virtualenv
$ virtualenv <ENV>
virtualenv
$ easy_install pip
$ pip install virtualenv
$ virtualenv <ENV>

This creates a folder <ENV> in the $PWD.

<ENV>/lib/pythonX.X/site-packages
virtualenvwrapper
virtualenvwrapper
$ pip install virtualenvwrapper
virtualenvwrapper
$ pip install virtualenvwrapper
Some simple environment vars need to go into .bashrc

export WORKON_HOME=$HOME/.virtualenv
source /usr/local/bin/virtualenvwrapper.sh
export PIP_VIRTUALENV_BASE=$WORKON_HOME
export PIP_RESPECT_VIRTUALENV=true
virtualenvwrapper
 $ pip install virtualenvwrapper
 Some simple environment vars need to go into .bashrc

 export WORKON_HOME=$HOME/.virtualenv
 source /usr/local/bin/virtualenvwrapper.sh
 export PIP_VIRTUALENV_BASE=$WORKON_HOME
 export PIP_RESPECT_VIRTUALENV=true

The last package that you should ever install
                  globally
virtualenv + virtualenvwrapper =
virtualenv + virtualenvwrapper =

       Can you guess it?
virtualenv + virtualenvwrapper =

       Can you guess it?
1up - pythonbrew
1up - pythonbrew
$ curl -kL http://xrl.us/pythonbrewinstall | bash
1up - pythonbrew
$ curl -kL http://xrl.us/pythonbrewinstall | bash
Some simple code needs to go into .bashrc

[[ -s $HOME/.pythonbrew/etc/bashrc ]] && source
$HOME/.pythonbrew/etc/bashrc
virtualenv + virtualenvwrapper + pythonbrew =
virtualenv + virtualenvwrapper + pythonbrew =

              Can you guess it?
virtualenv + virtualenvwrapper + pythonbrew =

              Can you guess it?
Using
    virtualenvwrapper
$ mkvirtualenv python-rules
$ workon python-rules
$ pip install pygett
$ deactivate
$ cdsitepackages
$ lssitepackages
$ rmvirtualenv python-rules
Using pythonbrew
$ pybrew list
$ pybrew install --force 2.7.2
$ pybrew switch 2.7.2
$ pybrew install --force 2.4.6
$ pybrew switch 2.4.6
$ pybrew venv create -p 2.7.2 python-rules
$ pybrew off
$ pybrew py awesome_script.py
Holy grail of
pythonbrew
Holy grail of
pythonbrew
Are you ready for this?
Holy grail of
  pythonbrew
    Are you ready for this?
Ok, maybe it’s not THAT epic ;)
Holy grail of
     pythonbrew
      Are you ready for this?
  Ok, maybe it’s not THAT epic ;)

$ pybrew py awesome_script.py
Holy grail of
               pythonbrew
                 Are you ready for this?
            Ok, maybe it’s not THAT epic ;)

       $ pybrew py awesome_script.py

What does this do?!?! It tests your python script against all
                 python versions! EPIC!
Let’s reiterate
Let’s reiterate
virtualenv & virtualenvwrapper allow you to
create environments and manage them with
the default system Python.
Let’s reiterate
virtualenv & virtualenvwrapper allow you to
create environments and manage them with
the default system Python.

pybrew is like virtualenv & virtualenvwrapper
had babies with a BRAWNDO ENERGY
DRINK! WIN AT PYTHON!
The EPIC end.
             Thanks for listening.

I’m Glen Zangirolami and I love developing EPIC
           Python projects that WIN.

               Twitter @glenbot
            http://theglenbot.com

Python environments

  • 1.
    Python Environments! Epically winning at Python! Glen Zangirolami Twitter @glenbot http://theglenbot.com Prepared for the 100th PyHou meetup.
  • 2.
  • 3.
    Environments! Porque? Isolation - Python packages and even versions live in their own little $HOME!
  • 4.
    Environments! Porque? Isolation - Python packages and even versions live in their own little $HOME! Permissions - Not everyone is 1337 and can be a sudoer.
  • 5.
    Environments! Porque? Isolation - Python packages and even versions live in their own little $HOME! Permissions - Not everyone is 1337 and can be a sudoer. Organization - each project can maintain it’s own requirements file of python packages and you don’t have version overlap.
  • 6.
    Environments! Porque? Isolation - Python packages and even versions live in their own little $HOME! Permissions - Not everyone is 1337 and can be a sudoer. Organization - each project can maintain it’s own requirements file of python packages and you don’t have version overlap. Anti-globalization - installing stuff to the system globally is generally not a good idea, unless it’s something like PIP.
  • 8.
  • 9.
    Ok fine. Buthow? virtualenv http://pypi.python.org/pypi/virtualenv virtualenvwrapper http://www.doughellmann.com/projects/ virtualenvwrapper/ pythonbrew https://github.com/utahta/pythonbrew
  • 10.
  • 11.
    virtualenv $ easy_install pip $pip install virtualenv $ virtualenv <ENV>
  • 12.
    virtualenv $ easy_install pip $pip install virtualenv $ virtualenv <ENV> This creates a folder <ENV> in the $PWD. <ENV>/lib/pythonX.X/site-packages
  • 13.
  • 14.
  • 15.
    virtualenvwrapper $ pip installvirtualenvwrapper Some simple environment vars need to go into .bashrc export WORKON_HOME=$HOME/.virtualenv source /usr/local/bin/virtualenvwrapper.sh export PIP_VIRTUALENV_BASE=$WORKON_HOME export PIP_RESPECT_VIRTUALENV=true
  • 16.
    virtualenvwrapper $ pipinstall virtualenvwrapper Some simple environment vars need to go into .bashrc export WORKON_HOME=$HOME/.virtualenv source /usr/local/bin/virtualenvwrapper.sh export PIP_VIRTUALENV_BASE=$WORKON_HOME export PIP_RESPECT_VIRTUALENV=true The last package that you should ever install globally
  • 17.
  • 18.
    virtualenv + virtualenvwrapper= Can you guess it?
  • 19.
    virtualenv + virtualenvwrapper= Can you guess it?
  • 20.
  • 21.
    1up - pythonbrew $curl -kL http://xrl.us/pythonbrewinstall | bash
  • 22.
    1up - pythonbrew $curl -kL http://xrl.us/pythonbrewinstall | bash Some simple code needs to go into .bashrc [[ -s $HOME/.pythonbrew/etc/bashrc ]] && source $HOME/.pythonbrew/etc/bashrc
  • 23.
  • 24.
    virtualenv + virtualenvwrapper+ pythonbrew = Can you guess it?
  • 25.
    virtualenv + virtualenvwrapper+ pythonbrew = Can you guess it?
  • 26.
    Using virtualenvwrapper $ mkvirtualenv python-rules $ workon python-rules $ pip install pygett $ deactivate $ cdsitepackages $ lssitepackages $ rmvirtualenv python-rules
  • 27.
    Using pythonbrew $ pybrewlist $ pybrew install --force 2.7.2 $ pybrew switch 2.7.2 $ pybrew install --force 2.4.6 $ pybrew switch 2.4.6 $ pybrew venv create -p 2.7.2 python-rules $ pybrew off $ pybrew py awesome_script.py
  • 28.
  • 29.
    Holy grail of pythonbrew Areyou ready for this?
  • 30.
    Holy grail of pythonbrew Are you ready for this? Ok, maybe it’s not THAT epic ;)
  • 31.
    Holy grail of pythonbrew Are you ready for this? Ok, maybe it’s not THAT epic ;) $ pybrew py awesome_script.py
  • 32.
    Holy grail of pythonbrew Are you ready for this? Ok, maybe it’s not THAT epic ;) $ pybrew py awesome_script.py What does this do?!?! It tests your python script against all python versions! EPIC!
  • 33.
  • 34.
    Let’s reiterate virtualenv &virtualenvwrapper allow you to create environments and manage them with the default system Python.
  • 35.
    Let’s reiterate virtualenv &virtualenvwrapper allow you to create environments and manage them with the default system Python. pybrew is like virtualenv & virtualenvwrapper had babies with a BRAWNDO ENERGY DRINK! WIN AT PYTHON!
  • 36.
    The EPIC end. Thanks for listening. I’m Glen Zangirolami and I love developing EPIC Python projects that WIN. Twitter @glenbot http://theglenbot.com