[英]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
. 我试图将项目从移动virtualenv
到buildout
,但我不认为我已经掌握了整个概念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. 我发现的所有教程都在与Zope
结合使用时讨论了buildout
,因为我没有使用它,因此看不到如何继续。
My file structure with virtualenv
is as follows: 我的virtualenv
文件结构如下:
myapp/
app.py
Which is run using /path/to/venvs/myapp/bin/python /path/to/myapp/script.py
. 使用/path/to/venvs/myapp/bin/python /path/to/myapp/script.py
。
With buildout
, my file structure is: 使用buildout
,我的文件结构是:
myapp/
app.py
bootstrap.py
buildout.cfg
Running python bootstrap.py
and bin/buildout
gives me these additional files: 运行python bootstrap.py
和bin/buildout
给我这些其他文件:
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? 忠告?
Buildout and virtualenv are actually tangentially related. Buildout和virtualenv实际上是切线相关的。 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. 扩展实际上是关于以受约束和受控的方式部署软件,其中virtualenv涉及封装python软件在其中运行的环境。 Buildout provides what virtualenv does within itself, and then wraps a bit more around it. Buildout提供了virtualenv自身内部的功能,然后围绕它进行了更多包装。
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. 该过程的一部分开始于创建一个干净的沙箱(virtualenv也可以提供此沙箱)-然后根据需要添加库,零件和零件。
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. 我不是建筑专家,但是我希望您的python主代码显示在目录结构中的“ bin”下,并且您将以某种方式从那里调用它。
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. 以下食谱将龙卷风作为鸡蛋安装,并在bin目录中使用正确的搜索路径创建python和myapp脚本以查找龙卷风鸡蛋。
[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}
In our project, we don't use Zope either. 在我们的项目中,我们也不使用Zope。 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. 我们花时间为学生写了一篇介绍如何使用zc.buildout
和标准python打包工具组织(并通过PyPI分发)他们的代码的zc.buildout
。 It is maybe useful to whoever reads this thread: http://www.idiap.ch/software/bob/docs/releases/v1.2.2/sphinx/html/OrganizeYourCode.html 对于阅读此线程的人来说可能很有用: http : //www.idiap.ch/software/bob/docs/releases/v1.2.2/sphinx/html/OrganizeYourCode.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.