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.
开发者_JS百科Advice?
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}
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.
In our project, we don't use Zope either. We took the time to write an introduction for students on how to organize (and distribute through PyPI) their code using zc.buildout
and standard python packaging tools. It is maybe useful to whoever reads this thread: http://www.idiap.ch/software/bob/docs/releases/v1.2.2/sphinx/html/OrganizeYourCode.html
精彩评论