如何使用 Buildout 从源代码安装我的项目?
我想使用 Buildout 来安装我的 将基于的项目及其依赖项分发到隔离环境。我的项目应该直接从源代码树(本地 Git 存储库)安装,并且未向 PyPI 注册。我该如何实现这个目标?
编辑:
感谢 M. Pieters,我能够弄清楚该怎么做。我发布了我的 buildout.cfg
供参考:
[buildout]
develop = .
parts = fbt
[fbt]
recipe = z3c.recipe.scripts
eggs = BuildTools
虽然我现在不需要它,但了解 mr.developer 将来肯定会派上用场。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您有 3 个选项,具体取决于您希望构建配置存在的位置以及您必须查看 git 存储库的选项。
请注意,就 Python 而言,生成的 Egg 是完全相同的。开发鸡蛋和“正常”鸡蛋之间的唯一区别是,开发鸡蛋会覆盖其他地方为该鸡蛋设置的任何版本要求;无论在其他地方发现什么其他版本的鸡蛋,它都会被使用。
在开发存储库中
只需使用
develop
选项。这将创建一个开发蛋,它与普通蛋一样,但没有版本检查,仅此而已。您的构建只需列出当前目录(setup.py 所在的位置)作为开发 Egg:
在不同的位置,
您需要能够访问 git 存储库才能创建新的签出。使用 mr.developer 拉入您的 git 存储库并自动将其标记为开发蛋:
通过此设置,mr.developer 将自动将 git 存储库签出到
src/
子目录,并将其添加到构建develop
选项中。使用 tarball 下载
github.com 等地方还提供了下载包含存储库当前内容的 tarball 的选项。您可以使用
find-links
选项将该 tarball 作为 Egg 源加载:然后 Buildout 将使用该特定的
find-links
条目来查找 Egg(前提是它)在其他地方找不到鸡蛋。You have 3 options, depending on where you want your buildout configuration to live and what options you have to check out your git repository.
Note that as far as Python is concerned, the resulting egg is exactly the same. The only difference between a development egg and a "normal" egg is that a development egg overrides any version requirements set elsewhere for that egg; it will be used regardless of what other versions of the egg are found elsewhere.
Inside the development repository
Just use the
develop
option. This creates a development egg, which is just the same as a normal egg but without a version check, nothing more, nothing less.Your buildout simply needs to list the current directory (where setup.py lives) as the development egg:
In a different location
You'll need to be able to reach the git repository for this to create a new checkout. Use mr.developer to pull in your git repository and automatically mark it as a development egg:
With this setup, mr.developer will automatically check out the git repository to the
src/
subdirectory and add that to the buildoutdevelop
option.Using a tarball download
Places like github.com also offer an option to download a tarball with the current contents of the repository. You could use that to load that tarball as an egg source with the
find-links
option:Buildout will then use that specific
find-links
entry to find the egg, provided it cannot find the egg elsewhere.通过使用 zc.buildout 的 develop 指令或使用 mr.developer 构建扩展,您可以轻松地使用 Buildout 来从存储库签出,您可以在其中定义要直接从给定存储库 URL 签出的包(支持git、svn 和其他版本控制系统)。
请参阅
http://pypi.python.org/pypi/mr.developer
You easily use Buildout with checkouts from repository by either using the develop directive of zc.buildout or using the mr.developer buildout extension where you can define the packages to be checkout directly from a given repository URL (supports git, svn and others version control systems).
See
http://pypi.python.org/pypi/mr.developer