From 5e9e22b927bfd5d8dbfb24159e5e985890ff8aab Mon Sep 17 00:00:00 2001 From: Michael Flaxman Date: Mon, 28 Feb 2022 15:17:23 -0600 Subject: [PATCH 1/7] use libsec bindings in tests prior to pypi update script --- clean.sh | 4 ---- clean_libsec.sh | 7 +++++++ update_pypi.sh | 40 ++++++++++++++++++++++++++-------------- 3 files changed, 33 insertions(+), 18 deletions(-) create mode 100755 clean_libsec.sh diff --git a/clean.sh b/clean.sh index 42aaaf3..1447b14 100755 --- a/clean.sh +++ b/clean.sh @@ -6,9 +6,5 @@ rm -rf .venv3/ rm -rf dist/ rm -rf build/ rm -rf buidl.egg-info/ -rm buidl/_libsec.c -rm buidl/_libsec.cpython-*-darwin.so -rm buidl/_libsec.o -rm buidl/_libsec.so find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf diff --git a/clean_libsec.sh b/clean_libsec.sh new file mode 100755 index 0000000..07634df --- /dev/null +++ b/clean_libsec.sh @@ -0,0 +1,7 @@ +#! /usr/bin/env bash + +set -o xtrace +rm -f buidl/_libsec.c +rm -f buidl/_libsec.cpython-*-darwin.so +rm -f buidl/_libsec.o +rm -f buidl/_libsec.so diff --git a/update_pypi.sh b/update_pypi.sh index 39f144f..5dd1f0b 100755 --- a/update_pypi.sh +++ b/update_pypi.sh @@ -9,22 +9,36 @@ deactivate # Abandon if anything errors set -e; -# Remove old files -rm -rf .venv3/ -rm -rf dist/ -rm -rf build/ -rm -rf buidl.egg-info/ -find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf - -# Tests +# Cleanup before getting started +./clean.sh +./clean_libsec.sh + +## RUN TESTS ## + +# Install libsec optimizations to make tests fast (this assumes libsecp256k1 is already installed) +python3 -m pip install -r requirements-libsec.txt +python3 -m pip install --editable . +cd buidl +python3 libsec_build.py +cd .. +# TODO: should this fail if libsec doesn't work? +python3 -c "from buidl import *; print('success') if is_libsec_enabled() else print('LIBSEC INSTALL FAIL')" + +# Actually run tests if [ -f requirements-test.txt ]; then python3 -m pip install -r requirements-test.txt; fi black --check . flake8 . pytest -v buidl/test/ pytest -v test_*.py +# Cleanup and reinstall build for pypi +./clean.sh + # Safety -git push +#FIXME +# git push + +## UPDATE PYPI ## # Virtualenv python3 --version @@ -42,13 +56,11 @@ python3 -m pip freeze python3 setup.py sdist bdist_wheel # Upload to PyPI python3 -m pip install --upgrade twine -python3 -m twine upload dist/* +# FIXME +python3 -m twine upload --repository testpypi dist/* # Cleanup -rm -rfv dist/ -rm -rfv buidl.egg-info/ -rm -rfv build/ -find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf +./clean.sh # Hackey timer # https://askubuntu.com/questions/1028924/how-do-i-use-seconds-inside-a-bash-script From bed12aa1d6607030f2c4dfe81405ca4765a0ac0f Mon Sep 17 00:00:00 2001 From: Michael Flaxman Date: Mon, 28 Feb 2022 15:20:06 -0600 Subject: [PATCH 2/7] oops --- update_pypi.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/update_pypi.sh b/update_pypi.sh index 5dd1f0b..761e139 100755 --- a/update_pypi.sh +++ b/update_pypi.sh @@ -35,8 +35,7 @@ pytest -v test_*.py ./clean.sh # Safety -#FIXME -# git push +git push ## UPDATE PYPI ## @@ -56,8 +55,9 @@ python3 -m pip freeze python3 setup.py sdist bdist_wheel # Upload to PyPI python3 -m pip install --upgrade twine -# FIXME -python3 -m twine upload --repository testpypi dist/* +# Use this line to upload to pypi testing repo instead: +# python3 -m twine upload --repository testpypi dist/* +python3 -m twine testpypi dist/* # Cleanup ./clean.sh From 600522f5c6897ab80617c8c82fdb5b69254750b5 Mon Sep 17 00:00:00 2001 From: Michael Flaxman Date: Tue, 1 Mar 2022 16:30:54 -0600 Subject: [PATCH 3/7] factor out clean_libsec --- clean.sh | 1 + clean_libsec.sh | 1 + install_libsec.sh | 13 +++++++++++++ update_pypi.sh | 14 ++++++-------- 4 files changed, 21 insertions(+), 8 deletions(-) create mode 100755 install_libsec.sh diff --git a/clean.sh b/clean.sh index 1447b14..876cfd7 100755 --- a/clean.sh +++ b/clean.sh @@ -1,6 +1,7 @@ #! /usr/bin/env bash set -o xtrace + pip3 uninstall buidl -y rm -rf .venv3/ rm -rf dist/ diff --git a/clean_libsec.sh b/clean_libsec.sh index 07634df..7b32350 100755 --- a/clean_libsec.sh +++ b/clean_libsec.sh @@ -1,6 +1,7 @@ #! /usr/bin/env bash set -o xtrace + rm -f buidl/_libsec.c rm -f buidl/_libsec.cpython-*-darwin.so rm -f buidl/_libsec.o diff --git a/install_libsec.sh b/install_libsec.sh new file mode 100755 index 0000000..c9b2bcc --- /dev/null +++ b/install_libsec.sh @@ -0,0 +1,13 @@ +#! /usr/bin/env bash + +# This assumes libsecp256k1 is already installed on the OS + +set -o xtrace + +python3 -m pip install -r requirements-libsec.txt +python3 -m pip install --editable . +cd buidl +python3 libsec_build.py +cd .. +# TODO: should this fail if libsec doesn't work? +python3 -c "from buidl import *; print('success') if is_libsec_enabled() else print('LIBSEC INSTALL FAIL')" diff --git a/update_pypi.sh b/update_pypi.sh index 761e139..8a7d774 100755 --- a/update_pypi.sh +++ b/update_pypi.sh @@ -15,14 +15,8 @@ set -e; ## RUN TESTS ## -# Install libsec optimizations to make tests fast (this assumes libsecp256k1 is already installed) -python3 -m pip install -r requirements-libsec.txt -python3 -m pip install --editable . -cd buidl -python3 libsec_build.py -cd .. -# TODO: should this fail if libsec doesn't work? -python3 -c "from buidl import *; print('success') if is_libsec_enabled() else print('LIBSEC INSTALL FAIL')" +# To make tests fast +./install_libsec.sh # Actually run tests if [ -f requirements-test.txt ]; then python3 -m pip install -r requirements-test.txt; fi @@ -33,6 +27,7 @@ pytest -v test_*.py # Cleanup and reinstall build for pypi ./clean.sh +./clean_libsec.sh # Safety git push @@ -62,6 +57,9 @@ python3 -m twine testpypi dist/* # Cleanup ./clean.sh +# Libsec is nice to have installed by default +./install_libsec.sh + # Hackey timer # https://askubuntu.com/questions/1028924/how-do-i-use-seconds-inside-a-bash-script hrs=$(( SECONDS/3600 )) From 409da7c8e49de00e736b5a00d6402aa7445de07a Mon Sep 17 00:00:00 2001 From: Michael Flaxman Date: Tue, 1 Mar 2022 17:05:03 -0600 Subject: [PATCH 4/7] note --- update_pypi.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/update_pypi.sh b/update_pypi.sh index 8a7d774..6673504 100755 --- a/update_pypi.sh +++ b/update_pypi.sh @@ -18,8 +18,10 @@ set -e; # To make tests fast ./install_libsec.sh -# Actually run tests +# Install testing requirements if [ -f requirements-test.txt ]; then python3 -m pip install -r requirements-test.txt; fi + +# Run tests black --check . flake8 . pytest -v buidl/test/ From f23c27d0ae2b7008c3485fa154eb83afdb5087bf Mon Sep 17 00:00:00 2001 From: Michael Flaxman Date: Tue, 1 Mar 2022 17:20:13 -0600 Subject: [PATCH 5/7] add docs folder to pypi build --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index b9c3ceb..ddaa9be 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,3 @@ include buidl/bip39_words.txt include buidl/slip39_words.txt +graft docs* From 16f496bc7b5b59e2556fbb766d96facbe4fbfc47 Mon Sep 17 00:00:00 2001 From: Michael Flaxman Date: Tue, 1 Mar 2022 17:22:27 -0600 Subject: [PATCH 6/7] hackey way to see multiwallet docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b21c3ab..4ba88f9 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ $ multiwallet.py Welcome to multiwallet... ``` -For more information on installing multiwallet, see [multiwallet.md](docs/multiwallet.md) or check out [this demo](https://twitter.com/mflaxman/status/1321503036724989952). +For more information on installing multiwallet, see [docs/multiwallet.md](https://github.com/buidl-bitcoin/buidl-python/blob/main/docs/multiwallet.md) or check out [this demo](https://twitter.com/mflaxman/status/1321503036724989952). `singlesweep.py` works the same way for sweeping out of paper wallets, but is intentionally undocumented. From e9bacac817f71000cc052a673b11dffaa5875e8d Mon Sep 17 00:00:00 2001 From: Michael Flaxman Date: Tue, 1 Mar 2022 17:26:01 -0600 Subject: [PATCH 7/7] readme note --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4ba88f9..c1af386 100644 --- a/README.md +++ b/README.md @@ -100,3 +100,4 @@ $ sudo make install $ git clone git@github.com:buidl-bitcoin/buidl-python.git && cd buidl-python && python3 -m pip install -r requirements-libsec.txt && python3 -m pip install --editable . && cd buidl && python3 libsec_build.py && cd .. && python3 -c "from buidl import *; print('success') if is_libsec_enabled() else print('LIBSEC INSTALL FAIL')" ``` +(Or run the included [`install_libsec.sh`](https://github.com/buidl-bitcoin/buidl-python/blob/main/install_libsec.sh) script)