Skip to content

Commit

Permalink
Extreme attempt, build all objects together, avoiding static library
Browse files Browse the repository at this point in the history
  • Loading branch information
lelit committed Jan 27, 2024
1 parent 062736f commit 877e07c
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions setup.py
Expand Up @@ -24,9 +24,19 @@


LIBPG_QUERY_DIR = here / 'libpg_query'
INCLUDE_DIR = LIBPG_QUERY_DIR / 'src' / 'postgres' / 'include'
SRC_DIR = LIBPG_QUERY_DIR / 'src'
INCLUDE_DIR = SRC_DIR / 'include'
PG_SRC_DIR = SRC_DIR / 'postgres'
PG_INCLUDE_DIR = PG_SRC_DIR / 'include'
VENDOR_DIR = LIBPG_QUERY_DIR / 'vendor'

SOURCES = ['pglast/parser.c']
SOURCES.extend(SRC_DIR.glob('*.c'))
SOURCES.extend(PG_SRC_DIR.glob('*.c'))
SOURCES.append(VENDOR_DIR / 'protobuf-c' / 'protobuf-c.c')
SOURCES.append(VENDOR_DIR / 'xxhash' / 'xxhash.c')
SOURCES.append(LIBPG_QUERY_DIR / 'protobuf' / 'pg_query.pb-c.c')


class BuildLibPgQueryFirst(build_ext):
def run(self):
Expand All @@ -38,17 +48,6 @@ def run(self):
super().run()


if sys.platform == 'win32':
libpg_query_extension_args = {
"libraries": ['pg_query'],
"library_dirs": [str(LIBPG_QUERY_DIR)]
}
else:
libpg_query_extension_args = {
"extra_objects": [str(LIBPG_QUERY_DIR / 'libpg_query.a')],
}


setup(
name="pglast",
version=VERSION,
Expand Down Expand Up @@ -83,19 +82,25 @@ def run(self):

packages=find_packages('.'),

cmdclass={'build_ext': BuildLibPgQueryFirst},
#cmdclass={'build_ext': BuildLibPgQueryFirst},
ext_modules=[
Extension(
'pglast.parser',
sources=['pglast/parser.c'],
sources=list(map(str, SOURCES)),
extra_compile_args=(['-Wno-unused-function',
'-Wno-unused-value',
'-Wno-unused-variable',
'-Wno-unused-but-set-variable',
'-Wno-sign-compare']
if sys.platform == 'linux'
else []),
include_dirs=list(
map(str, (LIBPG_QUERY_DIR, VENDOR_DIR, INCLUDE_DIR)
map(str, (LIBPG_QUERY_DIR, VENDOR_DIR, INCLUDE_DIR, PG_INCLUDE_DIR)
+
((INCLUDE_DIR / 'port' / 'win32',
INCLUDE_DIR / 'port' / 'win32_msvc')
((PG_INCLUDE_DIR / 'port' / 'win32',
PG_INCLUDE_DIR / 'port' / 'win32_msvc')
if sys.platform == 'win32'
else ()))),
**libpg_query_extension_args,
),
],

Expand Down

0 comments on commit 877e07c

Please sign in to comment.