是否可以预先创建一个 virtualenv 以在 hudson 构建中使用?
我正在遵循 heisel 上描述的 hudson/python/virtualenv CI 解决方案 的大纲.org,但其中的一个步骤确实令人烦恼,这就是配置专为 CI 运行而创建的 virtualenv 的部分:
pip install -q -E ./ve -r requirements.pip
pip install -q -E ./ve -r requirements-test.pip
这需要大量的时间来运行,并且每次源文件发生更改时我们最终将重新下载大量数据。
是否可以在 Hudson 中创建模板工作区,这样就可以检出到预先准备好的工作区中,而不是检出到裸露的工作区中?
I'm following the outline of the hudson/python/virtualenv CI solution described at heisel.org but one step of this is really chafing, and that's the part where the virtualenv, created just for the CI run, is configured:
pip install -q -E ./ve -r requirements.pip
pip install -q -E ./ve -r requirements-test.pip
This takes an inordinate amount of time to run, and every time a source file changes we'll end up re-downloading what amounts to a significant amount of data.
Is it possible to create template workspaces in Hudson, so that instead of checking out into a bare workspace it checks out into one that is pre-prepared?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这里有几个选项:
在源代码存储库中有一个存档,该存档会爆炸到
virtualenv/pip 安装。您需要使 virtualenv 起点可重新定位。
使用任何适合的 SCM 选项,以免清除工作区
构建之间(例如使用 svn update,或者不检查 Mercurial 的 Clean Build
选项)。然后将安装命令保留在构建脚本中,但将它们放入
在
if
语句下,因此它们仅在.pip_installed
文件不存在或设置了构建参数时运行(例如)。您也许可以获得克隆工作区 插件来做你想做的事
想。但这是另一种 SCM,我猜你可能不知道
因为 Hudson 不会从多个 SCM 中签出(请参阅此之前
问题有关解决此问题的一些想法)。
将 pip 配置设置为从
包的本地缓存。
Here are a couple options:
Have an archive in your source repository that blows up into the
virtualenv/pip install. You'll need to make the virtualenv starting point relocatable.
Use whatever SCM option is appropriate to not wipe out the workspace
between builds (e.g. Use svn update, or don't check Mercurial's Clean Build
option). Then keep the install commands in your build script, but put them in
under an
if
statement so they are only run (for example) if a.pip_installed
file is not present, or if a build parameter is set.You might be able to get the Clone Workspace plugin to do what you
want. But that's an alternative SCM, which I'm guessing you probably don't
want since Hudson won't check out from multiple SCMs (see this previous
question for some ideas about working around this).
It's probably also a good idea to set up your pip configuration to pull from a
local cache of packages.
一项增强功能是将 virtualenv 打包到由需求文件的哈希值命名的存档中。如果自上次构建以来需求文件没有更改,只需将存档解压到空的 virtualenv 目录中即可。如果需求文件已更改,则存档将不存在,因此您运行 pip install 来构建环境,然后将其存储在新存档中。
An enhancement is to package the virtualenv in an archive named by the hash of the requirements file. If the requirements file has not changed since the last build, just extract the archive into an empty virtualenv directory. If the requirements file has changed, an archive won't yet exist, so you run pip install to build the environment and then store it in a new archive.
如果您为每个工作区创建一个新的 venv,那么您只需在开始时安装所有 deps 一次,因此后续构建速度会更快。请参阅我的帖子,了解我编写的帮助解决问题的脚本:
“Pretty”持续集成Python
If you create a new venv per workspace then you only really have to install all the deps once at the beggining so subsequent builds are much faster. See my post for a script I wrote to help out:
"Pretty" Continuous Integration for Python