Source

dughh_talk /

Filename Size Date modified Message
ui
46 B
1.9 KB
128 B
123 B
118 B
134 B
779 B
4.4 KB
30 B
2.9 KB

A talk on virtualenv and pip

Well, here we go. The good, the bad and the ugly internals of Python packaging.

Let's get ready to rumble

  • First of all you need to bootstrap your environment.

  • Just run:

    hg clone http://bitbucket.org/dughh_talk
    cd dughh_talk
    bootstrap.[sh|bat]
    
  • Bear witness to teh magic!

Woohoo, what happened there?

Well easy, let's got through this step by step:

#!/bin/sh
virtualenv --no-site-packages env
source env/bin/activate
easy_install pip
pip install -r requirements.txt
deactivate

Setup the virtual environment

  • Create a pristine python environment w/o any strings attached in env:

    virtualenv --no-site-packages env
    
  • Activate the environment:

    source env/bin/activate
    

Bootstrap pip and install a package

  • First install pip:

    easy_install pip
    
  • Now install a package using pip:

    pip install docutils
    

Freeze the environment

Now this is the interesting part.

  • Running:

    pip freeze > requirements.txt
    
  • produces:

    cat requirements.txt
    docutils==0.6
    

Install frozen requirements

Now let's install the packages from the file created before.

  • Just run:

    pip install -r requirements.txt
    

Thank you, that's it

  • Now use this and create some awesome fabfiles for bootstrapping django environments!

  • Or use virtualenvwrapper to ease working on multiple projects.

  • Links:

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.