如何使用 Buildout 从源代码安装我的项目?

发布于 2024-11-01 17:51:26 字数 601 浏览 0 评论 0 原文

我想使用 Buildout 来安装我的 将基于的项目及其依赖项分发到隔离环境。我的项目应该直接从源代码树(本地 Git 存储库)安装,并且未向 PyPI 注册。我该如何实现这个目标?

编辑:

感谢 M. Pieters,我能够弄清楚该怎么做。我发布了我的 buildout.cfg 供参考:

[buildout]
develop = .
parts = fbt

[fbt]
recipe = z3c.recipe.scripts
eggs = BuildTools

虽然我现在不需要它,但了解 mr.developer 将来肯定会派上用场。

I want to use Buildout to install my Distribute-based project and its dependencies to an isolated environment. My project should be installed directly from the source tree (a local Git repository), and is not registered with PyPI. How do I accomplish this?

Edit:

Thanks to M. Pieters I was able to suss out what to do. I'm posting my buildout.cfg for reference:

[buildout]
develop = .
parts = fbt

[fbt]
recipe = z3c.recipe.scripts
eggs = BuildTools

Although I didn't need it right now, knowledge of mr.developer could definitely come in handy in the future.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

白首有我共你 2024-11-08 17:51:26

您有 3 个选项,具体取决于您希望构建配置存在的位置以及您必须查看 git 存储库的选项。

请注意,就 Python 而言,生成的 Egg 是完全相同的。开发鸡蛋和“正常”鸡蛋之间的唯一区别是,开发鸡蛋会覆盖其他地方为该鸡蛋设置的任何版本要求;无论在其他地方发现什么其他版本的鸡蛋,它都会被使用。

在开发存储库中

只需使用 develop 选项。这将创建一个开发蛋,它与普通蛋一样,但没有版本检查,仅此而已。

您的构建只需列出当前目录(setup.py 所在的位置)作为开发 Egg:

[buildout]
develop = .

在不同的位置,

您需要能够访问 git 存储库才能创建新的签出。使用 mr.developer 拉入您的 git 存储库并自动将其标记为开发蛋:

[buildout]
extensions = mr.developer
auto-checkout = package.name

[sources]
package.name = git url/to/package.name.git

通过此设置,mr.developer 将自动将 git 存储库签出到 src/ 子目录,并将其添加到构建 develop 选项中。

使用 tarball 下载

github.com 等地方还提供了下载包含存储库当前内容的 tarball 的选项。您可以使用 find-links 选项将该 tarball 作为 Egg 源加载:

[buildout]
find-links = http://github.com/yourname/package.name/tarball/version#egg=package.name-versionnumber
eggs = package.name

然后 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:

[buildout]
develop = .

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:

[buildout]
extensions = mr.developer
auto-checkout = package.name

[sources]
package.name = git url/to/package.name.git

With this setup, mr.developer will automatically check out the git repository to the src/ subdirectory and add that to the buildout develop 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]
find-links = http://github.com/yourname/package.name/tarball/version#egg=package.name-versionnumber
eggs = package.name

Buildout will then use that specific find-links entry to find the egg, provided it cannot find the egg elsewhere.

葮薆情 2024-11-08 17:51:26

通过使用 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文