Skip to content

don't embed Python code into libwallycore.so #501

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ $ brew install swig
- `--enable-swig-python`. Enable the [SWIG](http://www.swig.org/) Python
interface. The resulting shared library can be imported from Python using
the generated interface file `src/swig_python/wallycore/__init__.py`. (default: no).
- `--enable-python-manylinux`. Enable [manylinux](https://github.com/pypa/manylinux)
support for building [PyPI](https://pypi.org/) compatible python wheels. Using
the resulting library in non-python programs requires linking with `libpython.so`.
- `--enable-swig-java`. Enable the [SWIG](http://www.swig.org/) Java (JNI)
interface. After building, see `src/swig_java/src/com/blockstream/libwally/Wally.java`
for the Java interface definition (default: no).
Expand Down
15 changes: 7 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,11 @@ AC_SUBST([libsecp256k1_LIBS])
#
# Python facilities
#
AC_ARG_ENABLE(python-manylinux,
AS_HELP_STRING([--enable-python-manylinux],[enable manylinux Python compatibility (default: no)]),
[python_manylinux=$enableval], [python_manylinux=no])
AM_CONDITIONAL([PYTHON_MANYLINUX], [test "x$python_manylinux" = "xyes"])

AX_PYTHON_DEVEL([>= '2.7.0'])
dnl We set the 'optional' flag here because manylinux cibuildwheel containers
dnl don't include libpython*.so, and thus AX_PYTHON_DEVEL fails its final sanity
dnl check. We actually don't link against libpython*.so anyway, so all we care
dnl about is that we get a good value of $PYTHON_CPPFLAGS to pass to SWIG.
AX_PYTHON_DEVEL([>= '2.7.0'], [true])
AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != ""])


Expand All @@ -338,10 +337,10 @@ AC_ARG_ENABLE(swig-python,
[swig_python=$enableval], [swig_python=no])
AM_CONDITIONAL([USE_SWIG_PYTHON], [test "x$swig_python" = "xyes"])

AM_CONDITIONAL([RUN_PYTHON_TESTS], [test "$PYTHON" != "" -a "x$pythonexists" = "xyes"])
AM_CONDITIONAL([RUN_PYTHON_TESTS], [test -n "$PYTHON"])

if test "x$swig_python" = "xyes"; then
if test "x$pythonexists" != "xyes"; then
if test -z "$PYTHON_CPPFLAGS"; then
AC_MSG_FAILURE([ERROR: No usable Python was found for swig-python])
fi
if test "x$elements_abi" = "xno"; then
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _call(args, cwd=ABS_PATH):
_call(['git', 'submodule', 'update', '--init', '--recursive'])

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

Expand Down
58 changes: 10 additions & 48 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,7 @@ TOOLS_EXTRA_ARGS :=
endif

if USE_SWIG_PYTHON
noinst_LTLIBRARIES += libswig_python.la
libswig_python_la_SOURCES = swig_python/swig_python_wrap.c

libswig_python_la_CFLAGS = -I$(top_srcdir) $(libsecp256k1_CFLAGS) $(AM_CFLAGS) $(SWIG_PYTHON_CPPFLAGS) $(SWIG_WARN_CFLAGS) $(NOALIAS_CFLAGS)
if PYTHON_MANYLINUX
else
libswig_python_la_LIBADD = $(PYTHON_LIBS)
endif # PYTHON_MANYLINUX

BUILT_SOURCES = swig_python/swig_python_wrap.c
# Append our extra wrapper code to the package
swig_python/swig_python_wrap.c : swig_python/swig.i swig_python/python_extra.py_in
$(AM_V_at)$(SWIG) $(SWIG_PYTHON_OPT) $(SWIG_GEN_FLAGS) -outdir swig_python -o $@ $< && \
Expand All @@ -60,20 +52,6 @@ clean-local: clean-swig-python
endif # USE_SWIG_PYTHON

if RUN_PYTHON_TESTS
# Python requires the shared library to be named _wallycore.so
# for 'import' to work.
if IS_OSX
platform_dso_ext = dylib
else
if IS_MINGW
platform_dso_ext = dll
else
platform_dso_ext = so
endif # IS_MINGW
endif # IS_OSX
.libs/_wallycore.so: .libs/libwallycore.$(platform_dso_ext)
$(AM_V_at)ln -sfn libwallycore.$(platform_dso_ext) $@
PYTHON_TEST_DEPS = .libs/_wallycore.so
PYTHON_TEST = PYTHONDONTWRITEBYTECODE=1 $(PYTHON)
endif

Expand Down Expand Up @@ -224,83 +202,67 @@ endif

TESTS =
noinst_PROGRAMS =

if RUN_TESTS
TESTS += test_bech32
noinst_PROGRAMS += test_bech32
test_bech32_SOURCES = ctest/test_bech32.c
test_bech32_CFLAGS = -I$(top_srcdir)/include $(AM_CFLAGS)
test_bech32_LDADD = $(lib_LTLIBRARIES) @CTEST_EXTRA_STATIC@
if PYTHON_MANYLINUX
test_bech32_LDADD += $(PYTHON_LIBS)
endif

TESTS += test_psbt
noinst_PROGRAMS += test_psbt
test_psbt_SOURCES = ctest/test_psbt.c ccan/ccan/str/hex/hex.c
test_psbt_CFLAGS = -I$(top_srcdir)/include $(AM_CFLAGS) -I$(srcdir)/ccan
test_psbt_LDADD = $(lib_LTLIBRARIES) @CTEST_EXTRA_STATIC@
if PYTHON_MANYLINUX
test_psbt_LDADD += $(PYTHON_LIBS)
endif

TESTS += test_psbt_limits
noinst_PROGRAMS += test_psbt_limits
test_psbt_limits_SOURCES = ctest/test_psbt_limits.c ccan/ccan/str/hex/hex.c
test_psbt_limits_CFLAGS = -I$(top_srcdir)/include $(AM_CFLAGS) -I$(srcdir)/ccan
test_psbt_limits_LDADD = $(lib_LTLIBRARIES) @CTEST_EXTRA_STATIC@
if PYTHON_MANYLINUX
test_psbt_limits_LDADD += $(PYTHON_LIBS)
endif

if USE_PTHREAD
TESTS += test_clear
noinst_PROGRAMS += test_clear
test_clear_SOURCES = ctest/test_clear.c
test_clear_CFLAGS = -I$(top_srcdir)/include $(PTHREAD_CFLAGS) $(AM_CFLAGS) $(NOOPT_CFLAGS) $(NOBUILTIN_CFLAGS)
test_clear_LIBS = $(PTHREAD_LIBS)
test_clear_LDADD = $(lib_LTLIBRARIES) @CTEST_EXTRA_STATIC@
if PYTHON_MANYLINUX
test_clear_LDADD += $(PYTHON_LIBS)
endif
endif

TESTS += test_coinselection
noinst_PROGRAMS += test_coinselection
test_coinselection_SOURCES = ctest/test_coinselection.c
test_coinselection_CFLAGS = -I$(top_srcdir)/include $(AM_CFLAGS)
test_coinselection_LDADD = $(lib_LTLIBRARIES) @CTEST_EXTRA_STATIC@
if PYTHON_MANYLINUX
test_coinselection_LDADD += $(PYTHON_LIBS)
endif

TESTS += test_tx
noinst_PROGRAMS += test_tx
test_tx_SOURCES = ctest/test_tx.c
test_tx_CFLAGS = -I$(top_srcdir)/include $(AM_CFLAGS)
test_tx_LDADD = $(lib_LTLIBRARIES) @CTEST_EXTRA_STATIC@
if PYTHON_MANYLINUX
test_tx_LDADD += $(PYTHON_LIBS)
endif

TESTS += test_descriptor
noinst_PROGRAMS += test_descriptor
test_descriptor_SOURCES = ctest/test_descriptor.c
test_descriptor_CFLAGS = -I$(top_srcdir)/include $(AM_CFLAGS)
test_descriptor_LDADD = $(lib_LTLIBRARIES) @CTEST_EXTRA_STATIC@
if PYTHON_MANYLINUX
test_descriptor_LDADD += $(PYTHON_LIBS)
endif

if BUILD_ELEMENTS
TESTS += test_elements_tx
noinst_PROGRAMS += test_elements_tx
test_elements_tx_SOURCES = ctest/test_elements_tx.c
test_elements_tx_CFLAGS = -I$(top_srcdir)/include $(AM_CFLAGS)
test_elements_tx_LDADD = $(lib_LTLIBRARIES) @CTEST_EXTRA_STATIC@
if PYTHON_MANYLINUX
test_elements_tx_LDADD += $(PYTHON_LIBS)
endif
endif

check-local: check-libwallycore check-swig-python check-swig-java
$(AM_V_at)! grep '^int ' $(top_srcdir)/include/*.h # Missing WALLY_CORE_API

if SHARED_BUILD_ENABLED
if RUN_PYTHON_TESTS
check-libwallycore: $(PYTHON_TEST_DEPS)
check-libwallycore:
$(AM_V_at)$(PYTHON_TEST) test/test_address.py
$(AM_V_at)$(PYTHON_TEST) test/test_aes.py
$(AM_V_at)$(PYTHON_TEST) test/test_anti_exfil.py
Expand Down
Loading
Loading