1

I'm a little confused on the deployment process for Python. Let's say you

  1. create a brand new project with virtualenv
  2. source bin/activate
  3. pip install a few libraries
  4. write a simple hello world app
  5. pip freeze the dependencies

When I deploy this code into a machine, do I need first make sure the machine is sourced before installing dependencies? I don't mean to sound like a total noob but in the PHP world, I don't have to worry about this because it's already part of the project. All the dependencies are registered with the autoloader in place.

The steps would be:

  1. rsync the files (or any other method)
  2. source bin/activate
  3. pip install the dependencies from the pip freeze output file

It feels awkward, or just wrong and very error prone. What are the correct steps to make? I've searched around but it seems many tutorials/articles make an assumption that anyone reading the article has past python experience (imo).

UPDATE:

I've should have mentioned that I'm trying to understand how it hooks up with Apache.

1
  • The apache aspect is completely unrelated from deploying your app to the server. This is two questions really. Settings for apache are dependent upon the type of python app you are creating. Commented Jul 2, 2012 at 16:55

1 Answer 1

1
  1. Copy the directory containing the virtualenv. Exclude all virtualenv-generated files.
  2. On the destination machine, create a virtualenv over the directory.
  3. source bin/activate
  4. pip install -r requirements.txt

The first step is simplified if you use version control; you simply clone (Mercurial or Git) or checkout (Subversion) the code. All the virtualenv-generated files should have been in the appropriate ignore file. (.hgignore, .gitignore, .svnignore).

Sign up to request clarification or add additional context in comments.

3 Comments

So source bin/activate will work for Apache as well? I would have figured that the source command was for terminal usage only.
@user1218776: Where'd we mention Apache?
You can save a step and simplify by just doing: pip -E /path/to/env. Then you don't have to worry about sourcing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.