Skip to content

Commit

Permalink
Attempt to fix macOS-on-silicon wheel building
Browse files Browse the repository at this point in the history
The wheel produced for arm64 macs is b0rken, as if the shared object was
not properly linked against the static libpg_query.a library.

Try out suggestion found in
https://stackoverflow.com/questions/4597228/how-to-statically-link-a-library-when-compiling-a-python-module-extension,
where the static library if specified in extra_objects instead of a
normal library.
  • Loading branch information
lelit committed Jan 27, 2024
1 parent f152c99 commit 062736f
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions setup.py
Expand Up @@ -38,6 +38,17 @@ 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 @@ -74,17 +85,18 @@ def run(self):

cmdclass={'build_ext': BuildLibPgQueryFirst},
ext_modules=[
Extension('pglast.parser',
sources=['pglast/parser.c'],
libraries=['pg_query'],
include_dirs=list(
map(str, (LIBPG_QUERY_DIR, VENDOR_DIR, INCLUDE_DIR)
+
((INCLUDE_DIR / 'port' / 'win32',
INCLUDE_DIR / 'port' / 'win32_msvc')
if sys.platform == 'win32'
else ()))),
library_dirs=[str(LIBPG_QUERY_DIR)]),
Extension(
'pglast.parser',
sources=['pglast/parser.c'],
include_dirs=list(
map(str, (LIBPG_QUERY_DIR, VENDOR_DIR, INCLUDE_DIR)
+
((INCLUDE_DIR / 'port' / 'win32',
INCLUDE_DIR / 'port' / 'win32_msvc')
if sys.platform == 'win32'
else ()))),
**libpg_query_extension_args,
),
],

install_requires=[
Expand Down

0 comments on commit 062736f

Please sign in to comment.