Agreed this is a central problem of Python. In addition to learning the
language, the start-up ramp includes setuptools/easy_install, pip,
virtualenv, virtualenvwrapper, pypi, etc. Then you have to figure out if
it's better to install Python packages via apt or pip. But it's worth the
investment in time. Once the environment is set up, you have a reliable,
reproducible, cocoon in which to get work done.

This is the sequence I usually use on Ubuntu 10.04 LTS. Not that I'm an
expert, but this works for me:
sudo aptitude install build-essential python-dev python-setuptools  # Grab
most of what you need to build any Python package
sudo easy_install pip  # Get pip, because it's easier to use than
easy_install
sudo pip install virtualenv virtualenvwrapper  # Get virtualenv, because it
helps you isolate your Python environment for different projects
mkdir ~/.virtualenvs  # default location for virtualenv's

Add this line to your .bashrc:
source /usr/local/bin/virtualenvwrapper.sh

"source ~/.bashrc" to pick up the changes and then you're ready to make your
first virtualenv:
mkvirtualenv myproject

>From then on, you should always be inside a virtualenv when you install
packages. And always use "pip install <package>". The Ubuntu packages are
frozen in time and sometimes lag significantly. Read the docs for
"virtualenvwrapper", but the basic command to enter and switch between
projects is "workon myproject".

<end of tutorial>

Since you mentioned ssh/paramiko, you should also take a look at Fabric.
It's a nice tool for deployment. Happens to be written in Python, but I
think it only relies on paramiko.

I spent the last few weeks developing a Fabric script for building up an
Nginx/uWSGI/MySQL/virtualenv/Django production server on top of Ubuntu
(happens to be on AWS, but could be any VPS). It's great to be able to build
a server from scratch with one command. Just this afternoon I was thinking I
can't be the only one trying to build a production Python or Django server.
When I find some time, I'll share it at one of the usual spots.

Dave

Reply via email to