Closed gamesbook closed 3 years ago
For pyembedpg
to work, it downloads PostgreSQL source code and builds it on the fly. It then proceeds to cache this build for subsequent use. If you would like to build an extension; a similar idempotent setup phase would need to execute after PyEmbedPG is instantiated; yet before it is started. Then, the normal CREATE EXTENSION
calls would need to be made once the database is started.
As a rough example, lets say we want to install PostGIS. The version of PostgreSQL is installed by pyembedpg
. Then, PostGIS needs to have the dependencies for that extension installed. Something like this needs to execute in the source directory for the extension (replace $PG_VERSION
with the version string requested in pyembedpg
:
$ PATH=$PATH:~/.pyembedpg/$PG_VERSION/bin ./configure
$ make
$ make install
Subsequent executions of pyembedpg
using this cached directory will pick up PostGIS. However, the extension still needs to be created in the test suite's database. As root
is the default PG Admin, the following would need to execute (modified to the test configuration):
with psycopg2.connect(database='postgres', user='root', host='localhost', port=self.port) as conn:
with conn.cursor() as cursor:
cursor.execute('CREATE EXTENSION postgis')
As the dependency chains get quite in-depth with extensions; we leave including extensions as an exercise for consumers of this library.
Is this helpful?
I'll go ahead and mark this closed.
Thanks; as often happens I got pulled off this project. Will get back to it at sometime & give feedback.
If there are any clarifying answers we can give, please let us know.
What approach is recommended / possible to add extensions that are needed for testing? For example, https://postgis.net/install/ is one we commonly use.