Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to migrate from virtualenv to buildout?

I'm attempting to move a project from virtualenv to buildout, but I don't think I've grasped the whole concept of buildout. All the tutorials I've found discuss buildout in the context of using it with Zope, which I'm not using and therefore can't see how to continue.

My file structure with virtualenv is as follows:

myapp/
  app.py

Which is run using /path/to/venvs/myapp/bin/python /path/to/myapp/script.py.

With buildout, my file structure is:

myapp/
  app.py
  bootstrap.py
  buildout.cfg

Running python bootstrap.py and bin/buildout gives me these additional files:

myapp/
  bin/
    buildout
  eggs/
    setuptools-0.6c12dev_r80622-py2.6.egg
    tornado-1.0.1-py2.6.egg
  parts/

At this point I'm unsure how to "run" my app.

Advice?

like image 537
Phillip B Oldham Avatar asked Aug 20 '10 14:08

Phillip B Oldham


2 Answers

The following recipe will, install tornado as an egg and create a python and myapp script in the bin directory with the correct search path to find the tornado egg.

[buildout] 
parts = python 
eggs = tornado 
extra-paths = ${buildout:directory}

[python] 
recipe = zc.recipe.egg 
interpreter = python 
eggs = ${buildout:eggs} 
entry-points = myapp=app:main 
extra-paths = ${buildout:extra-paths}
like image 175
Michaelnt Avatar answered Sep 22 '22 22:09

Michaelnt


Buildout and virtualenv are actually tangentially related. Buildout is really about the deployment of software in a constrained and controlled fashion, where virtualenv is about encapsulating the environment that python software runs within. Buildout provides what virtualenv does within itself, and then wraps a bit more around it.

Think of buildout as the recipe set of how to take your code and lay it down onto a remote system ready to be run. Some of that process starts with creating a clean sandbox (which is what virtualenv can provide as well) - and then adding in libraries, pieces, and parts as you need.

I'm not a buildout expert, but I'd expect your python main code to show up under "bin" in your directory structure, and that you'd be somehow invoking it from there.

like image 39
heckj Avatar answered Sep 23 '22 22:09

heckj