Skip to content

Commit

Permalink
Update PostGIS to 3.5.1 (#130)
Browse files Browse the repository at this point in the history
Remove hardcoded Postgres extension version while at it and add an
EdgeQL-only version of the package.
  • Loading branch information
elprans authored Jan 9, 2025
1 parent 6449b72 commit df2d2e1
Show file tree
Hide file tree
Showing 9 changed files with 359 additions and 39 deletions.
4 changes: 2 additions & 2 deletions edgedbpkg/edgedb_ext/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .base import EdgeDBExtension
from .base import EdgeDBExtension, PGEXT_VERSION_AUTO

__all__ = ("EdgeDBExtension",)
__all__ = ("EdgeDBExtension", "PGEXT_VERSION_AUTO")
89 changes: 53 additions & 36 deletions edgedbpkg/edgedb_ext/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
+ "/tests/extension-testing/exts.mk"
)

PGEXT_VERSION_AUTO = "auto"


class EdgeDBExtension(packages.BuildSystemMakePackage):
# Populated in resolve() when this is built as top-level package.
bundle_deps: list[packages.BundledPackage] = []
_edb: edgedb.EdgeDB
_edb: edgedb.EdgeDB | None
_pgext: poetry_dep.Dependency

@classmethod
Expand All @@ -48,34 +50,62 @@ def resolve(
server_slot, _, version = version.rpartition("!")

if not server_slot:
raise RuntimeError(
"must specify EdgeDB version as epoch, eg 5!1.0"
)
if cls.is_universal():
edb = None
else:
raise RuntimeError(
"must specify EdgeDB version as epoch, eg 5!1.0"
)
else:
edb_ver = poetry_version.Version.parse(server_slot)
if edb_ver.minor is None:
edb_ver = edb_ver.replace(
release=dataclasses.replace(edb_ver.release, minor=0),
)

edb_ver = poetry_version.Version.parse(server_slot)
if edb_ver.minor is None:
edb_ver = edb_ver.replace(
release=dataclasses.replace(edb_ver.release, minor=0),
edb = edgedb.EdgeDB.resolve(
io,
version=f"v{edb_ver}",
is_release=edb_ver.dev is None,
target=target,
)

edb = edgedb.EdgeDB.resolve(
io,
version=f"v{edb_ver}",
is_release=edb_ver.dev is None,
target=target,
)

if requires is None:
requires = []
else:
requires = list(requires)

if name is None:
pkgname = cls.ident.removeprefix("edbext-")
else:
pkgname = str(name)

if edb is not None:
name = packages.canonicalize_name(f"{edb.name_slot}-{pkgname}")
else:
name = packages.canonicalize_name(pkgname)

ext = super().resolve(
io,
name=name,
version=version,
revision=revision,
is_release=is_release,
target=target,
requires=requires,
)
ext._edb = edb

pgext_ver = cls.get_pgext_ver()
if pgext_ver is PGEXT_VERSION_AUTO:
self_ver = ext.version.without_local().without_postrelease()
pgext_ver = self_ver.to_string()

pg_ext: pgext.PostgresCExtension | None
if pgext_ver:
# Find the postgres version
for dep in edb.get_requirements():
reqs = edb.get_requirements() if edb is not None else []
for dep in reqs:
if dep.name == "postgresql-edgedb":
pg = packages.get_bundled_pkg(dep)
break
Expand All @@ -102,25 +132,8 @@ def resolve(
else:
pg_ext = None

if name is None:
pkgname = cls.ident.removeprefix("edbext-")
else:
pkgname = str(name)

name = packages.canonicalize_name(f"{edb.name_slot}-{pkgname}")

ext = super().resolve(
io,
name=name,
version=version,
revision=revision,
is_release=is_release,
target=target,
requires=requires,
)
ext._edb = edb

if pg_ext is not None:
ext.add_dependency(pg_ext.to_dependency())
ext.bundle_deps.append(pg_ext)

return ext
Expand All @@ -137,6 +150,10 @@ def _get_sources(cls, version: str | None) -> list[packages.BaseSource]:
def get_pgext_ver(cls) -> str | None:
return None

@classmethod
def is_universal(cls) -> bool:
return False

@property
def supports_out_of_tree_builds(self) -> bool:
return False
Expand Down Expand Up @@ -171,7 +188,7 @@ def get_make_install_args(self, build: targets.Build) -> packages.Args:
}

def get_root_install_subdir(self, build: targets.Build) -> pathlib.Path:
if build.target.is_portable():
if build.target.is_portable() or self._edb is None:
return pathlib.Path(self.name_slot)
else:
return pathlib.Path(self._edb.name_slot)
Expand All @@ -180,7 +197,7 @@ def get_make_install_destdir_subdir(
self,
build: targets.Build,
) -> pathlib.Path:
if build.target.is_portable():
if build.target.is_portable() or self._edb is None:
return pathlib.Path("")
else:
return (
Expand Down
15 changes: 14 additions & 1 deletion edgedbpkg/edgedb_ext/postgis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PostGIS(edgedb_ext.EdgeDBExtension):

@classmethod
def get_pgext_ver(cls) -> str | None:
return "3.4.3"
return edgedb_ext.PGEXT_VERSION_AUTO

def get_make_install_destdir_subdir(
self,
Expand All @@ -35,3 +35,16 @@ def get_make_install_destdir_subdir(
return build.get_rel_install_prefix(self)
else:
return super().get_make_install_destdir_subdir(build)


# EdgeQL-only version of the above
class PostGISEdgeQL(PostGIS):
ident = "edbext-postgis-edgeql"

@classmethod
def get_pgext_ver(cls) -> str | None:
return None

@classmethod
def is_universal(cls) -> bool:
return True
94 changes: 94 additions & 0 deletions edgedbpkg/pgext/postgis/patches/pgext-postgis__gettext-305.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
From 24e4e6d4d94a4203e4a50000e25c983467a1c51e Mon Sep 17 00:00:00 2001
From: Elvis Pranskevichus <elvis@edgedb.com>
Date: Thu, 3 Oct 2024 23:12:22 -0700
Subject: [PATCH 4/4] Fix `make install` with gettext disabled

---
configure | 44 +++++++++++++++++++++++++++++++++++++++++++-
configure.ac | 1 +
2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 7283cb55e..3b9467974 100755
--- a/configure
+++ b/configure
@@ -718,7 +718,6 @@ GMSGFMT
MSGFMT
GETTEXT_MACRO_VERSION
USE_NLS
-MKDIR_P
SET_MAKE
HAVE_SFCGAL
SFCGAL
@@ -840,6 +839,7 @@ build_vendor
build_cpu
build
LIBTOOL
+MKDIR_P
INSTALL_DATA
INSTALL_SCRIPT
INSTALL_PROGRAM
@@ -2741,6 +2741,48 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'

test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'

+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5
+$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
+if test -z "$MKDIR_P"; then
+ if ${ac_cv_path_mkdir+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in mkdir gmkdir; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue
+ case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
+ 'mkdir (GNU coreutils) '* | \
+ 'mkdir (coreutils) '* | \
+ 'mkdir (fileutils) '4.1*)
+ ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
+ break 3;;
+ esac
+ done
+ done
+ done
+IFS=$as_save_IFS
+
+fi
+
+ test -d ./--version && rmdir ./--version
+ if test "${ac_cv_path_mkdir+set}" = set; then
+ MKDIR_P="$ac_cv_path_mkdir -p"
+ else
+ # As a last resort, use the slow shell script. Don't cache a
+ # value for MKDIR_P within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the value is a relative name.
+ MKDIR_P="$ac_install_sh -d"
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
+$as_echo "$MKDIR_P" >&6; }
+

# _LT_PROG_AR

diff --git a/configure.ac b/configure.ac
index 1ae526f47..1a319e4d6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -27,6 +27,7 @@ AH_TEMPLATE([HAVE_ASPRINTF])
AC_CONFIG_MACRO_DIR([macros])
AC_CONFIG_AUX_DIR([build-aux])
AC_PROG_INSTALL
+AC_PROG_MKDIR_P

dnl Overwrite _LT_PROG_AR
m4_pushdef([_LT_PROG_AR],
--
2.45.2

62 changes: 62 additions & 0 deletions edgedbpkg/pgext/postgis/patches/pgext-postgis__macos-fix-305.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
From 06ea94850d9e74510b5f580fc26cfcd1b5f7103f Mon Sep 17 00:00:00 2001
From: Elvis Pranskevichus <elvis@edgedb.com>
Date: Thu, 3 Oct 2024 17:37:17 -0700
Subject: [PATCH 3/4] Fix building on macOS

topology/Makefile clobbers bindir, which, in turn breaks the
`-bundle_loader` flag set by pgxs.mk.
---
topology/Makefile.in | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/topology/Makefile.in b/topology/Makefile.in
index ef8de4bb9..a322f394b 100644
--- a/topology/Makefile.in
+++ b/topology/Makefile.in
@@ -83,7 +83,7 @@ include $(PGXS)
# Set prefix variables _after_ the include of PGXS
prefix = @prefix@
exec_prefix = @exec_prefix@
-bindir = @bindir@
+my_bindir = @bindir@

# Set PERL _after_ the include of PGXS
PERL=@PERL@
@@ -99,7 +99,7 @@ $(OBJS): ../liblwgeom/.libs/liblwgeom.a ../libpgcommon/libpgcommon.a ../postgis_
# so that no prefix is included. This allows us to relocate to a temporary
# directory for regression testing.
ifeq ($(REGRESS),1)
- bindir=/bin
+ my_bindir=/bin
pkglibdir=/lib
datadir=/share
datamoduledir=contrib/postgis
@@ -177,20 +177,20 @@ distclean: clean
rm -f Makefile test/Makefile

installdir:
- mkdir -p $(DESTDIR)$(bindir)
+ mkdir -p $(DESTDIR)$(my_bindir)

install: install-importer install-exporter

install-importer: loader/pgtopo_import | installdir
- $(LIBTOOL) --mode=install $(INSTALL) $^ "$(DESTDIR)$(bindir)/pgtopo_import"
+ $(LIBTOOL) --mode=install $(INSTALL) $^ "$(DESTDIR)$(my_bindir)/pgtopo_import"

install-exporter: loader/pgtopo_export | installdir
- $(LIBTOOL) --mode=install $(INSTALL) $^ "$(DESTDIR)$(bindir)/pgtopo_export"
+ $(LIBTOOL) --mode=install $(INSTALL) $^ "$(DESTDIR)$(my_bindir)/pgtopo_export"

uninstall: uninstall-importer uninstall-exporter

uninstall-importer:
- rm -f '$(DESTDIR)$(bindir)/pgtopo_import'
+ rm -f '$(DESTDIR)$(my_bindir)/pgtopo_import'

uninstall-exporter:
- rm -f '$(DESTDIR)$(bindir)/pgtopo_export'
+ rm -f '$(DESTDIR)$(my_bindir)/pgtopo_export'
--
2.45.2

Loading

0 comments on commit df2d2e1

Please sign in to comment.