Skip to content

Commit 7e87b7a

Browse files
committed
src/Makefile.am: install Python module in src/swig_python/ for testing
Running the SWIG Python tests requires that Python is able to find the wallycore native extension. To save users from needing to build it manually and add its location to `PYTHONPATH` themselves, we add a target dependency in `src/Makefile.am` to trigger the Python build before we'll need the native extension for running the SWIG Python tests. It's unfortunate that we can't merely call `setup.py build` and then ask setuptools where it stashed its staging copy of the module, as there seems to be no accessible query interface for that information. So instead we have to tell `setup.py` to install the module to a location that we do know, and then we can pass that location in `PYTHONPATH` when we run the SWIG Python tests. See: #501 (comment)
1 parent 2e4caa6 commit 7e87b7a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ src/swig_java/swig_java_wrap.c
4646
src/swig_java/*.java
4747
src/swig_java/*.jar
4848
src/swig_java/src/com/blockstream/libwally
49+
src/swig_python/_wallycore.*.so
4950
src/swig_python/swig_python_wrap.c
5051
src/swig_python/wallycore/__init__.py
51-
src/swig_python/wallycore/wallycore.egg-info
52+
src/swig_python/wallycore*.egg-info
5253
tools/build-aux/m4/l*.m4
5354
tools/build-aux/test-driver
5455
tools/build-aux/*-e

src/Makefile.am

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ swig_python/swig_python_wrap.c : swig_python/swig.i swig_python/python_extra.py_
4646
cat swig_python/wallycore.py swig_python/python_extra.py_in > swig_python/wallycore/__init__.py && \
4747
rm swig_python/wallycore.py
4848

49-
PYTHON_SWIGTEST = LD_LIBRARY_PATH=.libs PYTHONDONTWRITEBYTECODE=1 $(PYTHON)
49+
PYTHON_SWIGTEST = LD_LIBRARY_PATH=.libs PYTHONPATH=swig_python PYTHONDONTWRITEBYTECODE=1 $(PYTHON)
50+
51+
if SHARED_BUILD_ENABLED
52+
SWIG_PYTHON_TEST_DEPS = swig_python/wallycore.egg-info
53+
swig_python/wallycore.egg-info :
54+
cd $(top_srcdir) && WALLY_ABI_PY_WHEEL_USE_LIB=shared $(PYTHON) setup.py install --install-lib src/swig_python/
55+
endif
5056

5157
clean-swig-python:
5258
$(AM_V_at)rm -f swig_python/swig_python_wrap.c swig_python/wallycore/__init__.py

0 commit comments

Comments
 (0)