Buildout, psycopg2, postgresql

1 投票
1 回答
1139 浏览
提问于 2025-04-16 05:55

我正在尝试创建一个buildout配置,目的是在需要的时候安装psycopg2这个包和从源代码安装postgres:

parts =
    ...
    postgre
    psycopg2
    ...

[postgre]
recipe = hexagonit.recipe.cmmi
url = ftp://ftp3.ua.postgresql.org/pub/mirrors/postgresql/source/v9.0.0/postgresql-9.0.0.tar.gz
configure-options =
    --without-readline

[psycopg2]
recipe = zc.recipe.egg:custom
egg = psycopg2
include-dirs =
    ${postgre:location}/include
library-dirs =
    ${postgre:location}/lib
rpath =
    ${postgre:location}/lib

问题是,不管用户是否已经安装了postgresql,它总是会从源代码重新构建postgresql。

我该如何让buildout检查一下用户是否已经具备构建psycopg2所需的所有东西呢?

1 个回答

2

可以做到这一点,但你需要自己写一个方法来进行检查。现在没有现成的办法可以满足你的需求。

另外一个选择是使用两个不同的配置文件。主要的 buildout.cfg 文件假设已经有 PostgreSQL 可用,所以它不会尝试去构建它。

第二个 withpostgres.cfg 文件可以像这样:

[buildout]
parts +=
    postgre
    psycopg2

[postgres]
... your existing one ...

[psycopg2]
... your existing one ...

需要从源代码构建的用户可以通过运行 bin/buildout -c withpostgres.cfg 来使用第二个配置。

这样能解决你的问题吗?

撰写回答