From 53df0e24ff13a9534c27a922cee38f02270ca44b Mon Sep 17 00:00:00 2001 From: Michel Pelletier Date: Sat, 28 Aug 2021 08:21:22 -0700 Subject: [PATCH] add plumbum commands --- README.md | 15 ++++++++++++++- postgresql/__init__.py | 13 ++++++------- setup.py | 5 +++-- tools/install_pg.sh | 4 ++-- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 211f9b2..f66dc45 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,15 @@ # postgresql-wheel -A Python wheel containing PostgreSQL + +A Python wheel for Linux containing the PostgreSQL database server. + +The wheel can be installed with pip: + +``` +$ pip install postgresql-wheel +Collecting postgresql-wheel + Using cached postgresql_wheel-13.4-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (13.8 MB) +Installing collected packages: postgresql-wheel +Successfully installed postgresql-wheel-13.4 +$ ipython +``` + diff --git a/postgresql/__init__.py b/postgresql/__init__.py index d9e117c..351b8d2 100644 --- a/postgresql/__init__.py +++ b/postgresql/__init__.py @@ -1,10 +1,9 @@ -from cffi import FFI +from pathlib import Path -ffibuilder = FFI() +from plumbum import local +import postgresql -ffibuilder.set_source("_postgresql", "") +local.path.append(Path(postgresql.__file__).parent / "bin") -ffibuilder.cdef("") - -if __name__ == "__main__": - ffibuilder.compile(verbose=True) +initdb = local.cmd.initdb +pg_ctl = local.cmd.pg_ctl diff --git a/setup.py b/setup.py index 9ce6381..c7a2a3e 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ def package_files(directory): return paths -extra_files = package_files("postgresql/binary") +extra_files = package_files("postgresql") setup( name="postgresql_wheel", @@ -21,6 +21,7 @@ def package_files(directory): packages=["postgresql"], package_data={"postgresql": extra_files}, setup_requires=["cffi"], - cffi_modules=["postgresql/__init__.py:ffibuilder"], + install_requires=["plumbum"], + cffi_modules=["postgresql/build.py:ffibuilder"], python_requires=">=3.8,<3.9", ) diff --git a/tools/install_pg.sh b/tools/install_pg.sh index 7de2df5..c337684 100644 --- a/tools/install_pg.sh +++ b/tools/install_pg.sh @@ -3,7 +3,7 @@ then VERSION=${BASH_REMATCH[1]} echo "Building ${VERSION}" else - exit -1 + VERSION=13.4 fi yum install -y zlib-devel readline-devel @@ -11,7 +11,7 @@ curl -L -O https://ftp.postgresql.org/pub/source/v13.4/postgresql-${VERSION}.tar tar -xzf postgresql-${VERSION}.tar.gz cd postgresql-${VERSION} -./configure --prefix=`pwd`/../postgresql/binary +./configure --prefix=`pwd`/../postgresql make -j 4 make install cd ..