Skip to content

Commit

Permalink
setup.py: support optionally building libwally-core as a shared library
Browse files Browse the repository at this point in the history
Iff the environment contains WALLY_ABI_PY_WHEEL_USE_DSO=1, then:

 * setup.py will configure and build libwally-core as a shared library;
 * the Python native extension library will not contain any
   libwally-core or libsecp256k1 code; and
 * the dynamic linker will need to find and load libwallycore.so.1
   whenever the Python native extension is loaded.
  • Loading branch information
whitslack committed Sep 3, 2023
1 parent d5dee06 commit 84d2b50
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
import copy, os, platform, shutil
import distutils.sysconfig

CONFIGURE_ARGS = ['--disable-shared', '--enable-static', '--with-pic',
build_shared = os.environ.get('WALLY_ABI_PY_WHEEL_USE_DSO', '').lower() not in ['', '0', 'false', 'no', 'n', 'off']
if build_shared:
CONFIGURE_ARGS = ['--enable-shared', '--disable-static']
else:
CONFIGURE_ARGS = ['--disable-shared', '--enable-static', '--with-pic']

CONFIGURE_ARGS += [
'--enable-swig-python', '--enable-python-manylinux',
'--disable-swig-java', '--disable-tests', '--disable-dependency-tracking']

Expand Down Expand Up @@ -81,8 +87,8 @@ def call(args):
'_wallycore',
define_macros=define_macros,
include_dirs=include_dirs,
library_dirs=['src/.libs', 'src/secp256k1/.libs'],
libraries=['wallycore', 'secp256k1'],
library_dirs=['src/.libs'] + ([] if build_shared else ['src/secp256k1/.libs']),
libraries=['wallycore'] + ([] if build_shared else ['secp256k1']),
extra_compile_args=extra_compile_args,
sources=[
'src/swig_python/swig_wrap.c' if is_windows else 'src/swig_python/swig_python_wrap.c',
Expand Down

0 comments on commit 84d2b50

Please sign in to comment.