diff --git a/edgedbpkg/edgedb/__init__.py b/edgedbpkg/edgedb/__init__.py index 4f2babd5..465f781f 100644 --- a/edgedbpkg/edgedb/__init__.py +++ b/edgedbpkg/edgedb/__init__.py @@ -73,7 +73,7 @@ class EdgeDB(packages.BundledPythonPackage): ">=5.0.dev1": [ "postgresql-edgedb (~= 15.0)", "python-edgedb (~= 3.11.0)", - "pgext-pgvector", + "pgext-pgvector (~= 0.6.0)", ], } @@ -88,6 +88,7 @@ class EdgeDB(packages.BundledPythonPackage): python_bundle.Python(version="3.11.3"), pyentrypoint.PyEntryPoint(version="1.0.0"), pgvector.PgVector("v0.4.2"), + pgvector.PgVector("v0.6.0"), ] @classmethod diff --git a/edgedbpkg/pgbundle/__init__.py b/edgedbpkg/pgbundle/__init__.py index 5cbe60ac..1650e313 100644 --- a/edgedbpkg/pgbundle/__init__.py +++ b/edgedbpkg/pgbundle/__init__.py @@ -29,6 +29,15 @@ class PostgreSQLBundle(packages.BundledPackage): bundle_deps: list[packages.BundledPackage] + artifact_requirements = { + "<16.0": [ + "pgext-pgvector (== 0.4.2)", + ], + ">=16.0": [ + "pgext-pgvector (~= 0.6.0)", + ], + } + @classmethod def resolve( cls, @@ -55,20 +64,18 @@ def resolve( bundle.bundle_deps = [ postgres, pgvector.PgVector("v0.4.2"), + pgvector.PgVector("v0.6.0"), ] return bundle def get_requirements(self) -> list[poetry_dep.Dependency]: - req_spec = [ - f"postgresql-edgedb (== {self.version})", - "pgext-pgvector", - ] - - reqs = [] - for item in req_spec: - reqs.append(poetry_dep.Dependency.create_from_pep_508(item)) - + reqs = super().get_requirements() + reqs.append( + poetry_dep.Dependency.create_from_pep_508( + f"postgresql-edgedb (== {self.version})" + ), + ) return reqs def get_configure_script(self, build: targets.Build) -> str: diff --git a/edgedbpkg/pgext/pgvector/__init__.py b/edgedbpkg/pgext/pgvector/__init__.py index 3eff1c13..c3eb98c2 100644 --- a/edgedbpkg/pgext/pgvector/__init__.py +++ b/edgedbpkg/pgext/pgvector/__init__.py @@ -4,6 +4,7 @@ Any, ) +import re import shlex from poetry.core.semver import version as poetry_version @@ -104,3 +105,31 @@ def get_make_env(self, build: targets.Build, wd: str) -> str: linebreaks=False, force_args_eq=True, ) + + def get_make_install_env(self, build: targets.Build, wd: str) -> str: + return build.sh_format_args( + { + "PG_CONFIG": build.sh_get_command("pg_config_install"), + "USE_PGXS": "1", + }, + linebreaks=False, + force_args_eq=True, + ) + + def get_patches(self) -> dict[str, list[tuple[str, str]]]: + v = f"{self.version.major}{self.version.minor}" + + patches = dict(super().get_patches()) + for pkg, pkg_patches in patches.items(): + if pkg == self.name: + filtered = [] + for i, (pn, pfile) in enumerate(list(pkg_patches)): + m = re.match(r"^.*-(\d+)$", pn) + if m and m.group(1) != v: + pass + else: + filtered.append((pn, pfile)) + patches[pkg] = filtered + break + + return patches diff --git a/edgedbpkg/pgext/pgvector/ignore.list b/edgedbpkg/pgext/pgvector/ignore.list new file mode 100644 index 00000000..6e780acb --- /dev/null +++ b/edgedbpkg/pgext/pgvector/ignore.list @@ -0,0 +1 @@ +{includedir}/**/*.h diff --git a/edgedbpkg/pgext/pgvector/patches/pgext-pgvector__Fix-CFLAGS.patch b/edgedbpkg/pgext/pgvector/patches/pgext-pgvector__Fix-CFLAGS-04.patch similarity index 100% rename from edgedbpkg/pgext/pgvector/patches/pgext-pgvector__Fix-CFLAGS.patch rename to edgedbpkg/pgext/pgvector/patches/pgext-pgvector__Fix-CFLAGS-04.patch diff --git a/edgedbpkg/pgext/pgvector/patches/pgext-pgvector__Fix-CFLAGS-06.patch b/edgedbpkg/pgext/pgvector/patches/pgext-pgvector__Fix-CFLAGS-06.patch new file mode 100644 index 00000000..d618f94a --- /dev/null +++ b/edgedbpkg/pgext/pgvector/patches/pgext-pgvector__Fix-CFLAGS-06.patch @@ -0,0 +1,25 @@ +From 50e0ecd8509f292dae18a11678548327e70f94b0 Mon Sep 17 00:00:00 2001 +From: Elvis Pranskevichus +Date: Thu, 8 Jun 2023 08:59:48 -0700 +Subject: [PATCH] Fix CFLAGS + +--- + Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index 3dc78f8..275acc6 100644 +--- a/Makefile ++++ b/Makefile +@@ -10,7 +10,7 @@ TESTS = $(wildcard test/sql/*.sql) + REGRESS = $(patsubst test/sql/%.sql,%,$(TESTS)) + REGRESS_OPTS = --inputdir=test --load-extension=$(EXTENSION) + +-OPTFLAGS = -march=native ++OPTFLAGS = + + # Mac ARM doesn't support -march=native + ifeq ($(shell uname -s), Darwin) +-- +2.43.0 + diff --git a/edgedbpkg/pgext/pgvector/patches/pgext-pgvector__Fix-build-warning.patch b/edgedbpkg/pgext/pgvector/patches/pgext-pgvector__Fix-build-warning-04.patch similarity index 100% rename from edgedbpkg/pgext/pgvector/patches/pgext-pgvector__Fix-build-warning.patch rename to edgedbpkg/pgext/pgvector/patches/pgext-pgvector__Fix-build-warning-04.patch diff --git a/edgedbpkg/postgresql/__init__.py b/edgedbpkg/postgresql/__init__.py index 14d48c52..67327dea 100644 --- a/edgedbpkg/postgresql/__init__.py +++ b/edgedbpkg/postgresql/__init__.py @@ -172,6 +172,7 @@ def get_build_tools(self, build: targets.Build) -> dict[str, pathlib.Path]: bindir = build.get_install_path("bin").relative_to("/") datadir = build.get_install_path("data") libdir = build.get_install_path("lib") + includedir = build.get_install_path("include") builddir_hlp = build.get_build_dir(self, relative_to="helpers") # Since we are using a temporary Postgres installation, @@ -207,6 +208,38 @@ def get_build_tools(self, build: targets.Build) -> dict[str, pathlib.Path]: "pg_config_wrapper.py", wrapper, relative_to="sourceroot" ) + # Same, but for install-time, so includes more paths + wrapper = textwrap.dedent( + f"""\ + import pathlib + import subprocess + import sys + + path = ( + pathlib.Path(__file__).parent / "{builddir_hlp}" / "_install" + ).resolve() + + pgc = path / "{bindir}" / "pg_config" + + proc = subprocess.run( + [pgc] + sys.argv[1:], + check=True, stdout=subprocess.PIPE, + universal_newlines=True) + + for line in proc.stdout.split('\\n'): + if ('{datadir}' in line or + '{includedir}' in line or + ('{libdir}' in line and 'pgxs' not in line)): + line = line.replace(str(path), '') + print(line) + """ + ) + + install_wrapper_cmd = build.write_helper( + "pg_config_install_wrapper.py", wrapper, relative_to="sourceroot" + ) + return { "pg_config": wrapper_cmd, + "pg_config_install": install_wrapper_cmd, } diff --git a/edgedbpkg/python/__init__.py b/edgedbpkg/python/__init__.py index b2115a3f..5dd3bfc3 100644 --- a/edgedbpkg/python/__init__.py +++ b/edgedbpkg/python/__init__.py @@ -117,9 +117,9 @@ def get_configure_script(self, build: targets.Build) -> str: ) if platform.system() == "Darwin": - configure_flags[ - "--enable-universalsdk" - ] = "!$(xcrun --show-sdk-path)" + configure_flags["--enable-universalsdk"] = ( + "!$(xcrun --show-sdk-path)" + ) arch = build.target.machine_architecture if arch == "x86_64": configure_flags["--with-universal-archs"] = "intel-64" @@ -144,9 +144,9 @@ def get_configure_script(self, build: targets.Build) -> str: ) openssl_path /= build.get_full_install_prefix().relative_to("/") configure_flags["--with-openssl"] = openssl_path - configure_flags[ - "--with-openssl-rpath" - ] = openssl_pkg.get_shlib_paths(build)[0] + configure_flags["--with-openssl-rpath"] = ( + openssl_pkg.get_shlib_paths(build)[0] + ) self.configure_dependency(build, configure_flags, "uuid", "LIBUUID") self.configure_dependency(build, configure_flags, "zlib", "ZLIB")