python: run swig python tests from a virtualenv
What changed, and why it matters
This commit changes how Python tests are run during the build process. Instead of running Python test scripts directly against the built library files, it now creates a temporary Python virtual environment, installs the built 'wallycore' package as a wheel into that environment, and runs the tests from there. This is purely a testing/CI infrastructure change and does not alter any cryptographic or security-sensitive code.
No security action required. This is a build/test hygiene change. Reviewers may optionally verify that the virtualenv creation and pip install steps work correctly in their CI environment.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies src/Makefile.am to refactor the check-swig-python target. It removes the PYTHON_SWIGTEST variable (which set PYTHONPATH to .libs:swig_python) and replaces direct Python invocations with creation of a virtualenv at $(top_builddir)/venv, pip-installing $(top_srcdir), and running the same contrib test scripts via the venv’s Python interpreter. The change ensures tests exercise the installed wheel rather than the in-tree build artifacts. There is no modification to library source code, bindings, or test logic.
Changed components
src/Makefile.amPython SWIG test target (check-swig-python)Inspect captured patch +16 / −15
diff --git a/src/Makefile.am b/src/Makefile.am
index 26b5fde..5615479 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -54,8 +54,6 @@ swig_python/swig_python_wrap.c : swig_python/swig.i swig_python/python_extra.py_
cat swig_python/wallycore.py swig_python/python_extra.py_in > swig_python/wallycore/__init__.py && \
rm swig_python/wallycore.py
-PYTHON_SWIGTEST = PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=.libs:swig_python $(PYTHON)
-
clean-swig-python:
$(AM_V_at)rm -f swig_python/swig_python_wrap.c swig_python/wallycore/__init__.py
clean-local: clean-swig-python
@@ -339,20 +337,23 @@ if BUILD_ELEMENTS
endif
if USE_SWIG_PYTHON
-check-swig-python: $(SWIG_PYTHON_TEST_DEPS)
- $(AM_V_at)$(PYTHON_SWIGTEST) swig_python/contrib/aes.py
- $(AM_V_at)$(PYTHON_SWIGTEST) swig_python/contrib/bip32.py
- $(AM_V_at)$(PYTHON_SWIGTEST) swig_python/contrib/coinselection.py
- $(AM_V_at)$(PYTHON_SWIGTEST) swig_python/contrib/descriptor.py
- $(AM_V_at)$(PYTHON_SWIGTEST) swig_python/contrib/mnemonic.py
- $(AM_V_at)$(PYTHON_SWIGTEST) swig_python/contrib/psbt.py
- $(AM_V_at)$(PYTHON_SWIGTEST) swig_python/contrib/sha.py
- $(AM_V_at)$(PYTHON_SWIGTEST) swig_python/contrib/signmessage.py
- $(AM_V_at)$(PYTHON_SWIGTEST) swig_python/contrib/tx.py
- $(AM_V_at)$(PYTHON_SWIGTEST) pyexample/anti-exfil.py
+check-swig-python:
+ $(AM_V_at)$(PYTHON) -m virtualenv $(top_builddir)/venv
+ $(AM_V_at)$(top_builddir)/venv/bin/python -m pip install $(top_srcdir)
+ $(AM_V_at)$(top_builddir)/venv/bin/python swig_python/contrib/aes.py
+ $(AM_V_at)$(top_builddir)/venv/bin/python swig_python/contrib/aes.py
+ $(AM_V_at)$(top_builddir)/venv/bin/python swig_python/contrib/bip32.py
+ $(AM_V_at)$(top_builddir)/venv/bin/python swig_python/contrib/coinselection.py
+ $(AM_V_at)$(top_builddir)/venv/bin/python swig_python/contrib/descriptor.py
+ $(AM_V_at)$(top_builddir)/venv/bin/python swig_python/contrib/mnemonic.py
+ $(AM_V_at)$(top_builddir)/venv/bin/python swig_python/contrib/psbt.py
+ $(AM_V_at)$(top_builddir)/venv/bin/python swig_python/contrib/sha.py
+ $(AM_V_at)$(top_builddir)/venv/bin/python swig_python/contrib/signmessage.py
+ $(AM_V_at)$(top_builddir)/venv/bin/python swig_python/contrib/tx.py
+ $(AM_V_at)$(top_builddir)/venv/bin/python pyexample/anti-exfil.py
if BUILD_ELEMENTS
- $(AM_V_at)$(PYTHON_SWIGTEST) swig_python/contrib/elements_tx.py
- $(AM_V_at)$(PYTHON_SWIGTEST) pyexample/liquid/receive-send.py
+ $(AM_V_at)$(top_builddir)/venv/bin/python swig_python/contrib/elements_tx.py
+ $(AM_V_at)$(top_builddir)/venv/bin/python pyexample/liquid/receive-send.py
endif
else # USE_SWIG_PYTHON
check-swig-python: ;
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.