Fix compilation of libpq_query in production builds
@@ -286,21 +286,13 @@ def _compile_postgres(build_base, *,
def _compile_libpg_query():
- proc = subprocess.run(
- ['git', 'submodule', 'status', 'edb/pgsql/parser/libpg_query'],
- stdout=subprocess.PIPE,
- universal_newlines=True,
- check=True,
- cwd=ROOT_PATH,
- )
- status = proc.stdout
- if status[0] == '-':
- print('libpg_query submodule not initialized, '
- 'run `git submodule init; git submodule update`')
- exit(1)
-
dir = (ROOT_PATH / 'edb' / 'pgsql' / 'parser' / 'libpg_query').resolve()
+ if not (dir / 'README.md').exists():
+ print('libpg_query submodule has not been initialized, '
+ 'run `git submodule update --init --recursive`')
+ exit(1)
+
subprocess.run(
['make'] + ['build', '-j', str(max(os.cpu_count() - 1, 1))],
cwd=str(dir), check=True)
@@ -588,14 +580,17 @@ class build_postgres(setuptools.Command):
produce_compile_commands_json=self.compile_commands,
)
+
class build_libpg_query(setuptools.Command):
description = "build libpg_query"
- user_options = []
+ user_options: list[str] = []
+
+ editable_mode: bool
def initialize_options(self):
- pass
+ self.editable_mode = False
def finalize_options(self):
pass
@@ -603,6 +598,7 @@ class build_libpg_query(setuptools.Command):
def run(self):
_compile_libpg_query()
+
class build_ext(setuptools_build_ext.build_ext):
user_options = setuptools_build_ext.build_ext.user_options + [
