用于构建 openGauss-connector-python-psycopg2 的镜像
1.2K
The goal of the manylinux project is to provide a convenient way to distribute binary Python extensions as wheels on Linux. This effort has produced PEP 513 (manylinux1), PEP 571 (manylinux2010), PEP 599 (manylinux2014) and PEP 600 (manylinux_x_y). -----来自 manylinux 仓库
这个镜像是基于 PEP599 定义的 manylinux2014 版本(x86_64和arm64 均为 CentOS 7 系统),内置了编译好的用于 opengauss 的 libpq.so 及其相关依赖,以及编译 psycopg2 所需的 pg_config 二进制,用于构建用于 openGauss 的 Python 驱动: openGauss-connector-python-psycopg2
使用该镜像可以直接在容器内执行以下指令进行全版本 wheel 包的构建:
# active db envrionment
source ~/.bashrc
export GIT_REPO=${GIT_REPO:-https://gitee.com/opengauss/openGauss-connector-python-psycopg2.git}
export GIT_BRANCH=${GIT_BRANCH:-master}
export PSYCOPG_VERSION=$(TZ=Asia/Shanghai date "+%Y%m%d.%H%M")
git clone --filter=blob:none --depth 1 --branch $GIT_BRANCH $GIT_REPO
cd $(basename $GIT_REPO .git)
sed -i "s/^PSYCOPG_VERSION.*/PSYCOPG_VERSION=\"$PSYCOPG_VERSION\"/g" setup.py
for py_version in /opt/python/*; do
# Generate wheel which not include required libs to ./dist directory
$py_version/bin/python setup.py bdist_wheel
done
for whl in ./dist/*.whl; do
# Repair dynamic libs for every wheel, and generate new wheel to ./wheelhouse
auditwheel repair $whl
done
echo "Wheels generated successfully to `pwd`/wheelhouse"
构建完成后,所有的 wheel 包都在仓库目录下的 wheelhouse 目录中,可根据不同的使用场景进行分发。
首先,为了编译能用于 opengauss 的 psycopg2 驱动,必须将使用 opengauss server 编译出来的 libpq及相关依赖,因为:
其次,现在社区提供的安装包方案是:提供给用户两个目录,一个 psycopg2 目录和一个依赖动态库的 lib 目录,用户使用时需将 lib 添加到 LD_LIBRARY_PATH 的环境变量中,以使得被驱动调用到。这样的方式有几个弊端:
LD_LIBRARY_PATH 的方式会导致驱动所在服务器其他的进程如果也依赖同名的动态库时,错误的引用到驱动的包,造成不必要的麻烦;the presence of too-recent versioned symbols,所以需在容器中重新编译相关依赖;而使用该镜像编译出来的 wheel 包有这些好处:
LD_LIBRARY_PATH 环境变量,也避免了和系统库重名的问题。pip install <name.whl> 即可快速安装完成。Content type
Image
Digest
sha256:8ff1b4901…
Size
760.7 MB
Last updated
about 3 years ago
docker pull vimiix/og_psycopg2_builder