/ build.sh
build.sh
1 #!/bin/bash 2 set -eo pipefail 3 4 repo_name=`git config remote.origin.url | sed -e 's,^.*/,,;s/\.git$//' | tr A-Z_ a-z-` 5 echo "=== Building package: $repo_name" 6 7 echo "=== Create and set up virtual environment" 8 [ -d .venv ] || python3 -m venv .env 9 . .env/bin/activate 10 echo "=== Install requirements" 11 pip3 install wheel 12 pip3 install -r requirements_dev.txt 13 echo "=== Run pre-commit" 14 pre-commit run --all-files 15 16 echo "=== Clone and build circuitpython unix port" 17 [ -e circuitpython/py/py.mk ] || git clone --shallow-since=2021-07-01 https://github.com/adafruit/circuitpython 18 [ -e circuitpython/lib/libffi/autogen.sh ] || (cd circuitpython && git submodule update --init lib/libffi lib/axtls lib/berkeley-db-1.xx tools/huffman lib/uzlib extmod/ulab) 19 [ -x circuitpython/ports/unix/micropython ] || ( 20 make -C circuitpython/mpy-cross -j$(nproc) 21 make -C circuitpython/ports/unix -j$(nproc) deplibs 22 make -C circuitpython/ports/unix -j$(nproc) DEBUG=1 STRIP=: 23 ) 24 25 echo "=== Run tests" 26 python -m jepler_udecimal.test 27 28 run-tests () { 29 env MICROPYPATH=. PYTHONPATH=. MICROPY_MICROPYTHON=circuitpython/ports/unix/micropython circuitpython/tests/run-tests.py "$@" 30 } 31 32 run-tests --clean-failures 33 if ! run-tests -d examples; then 34 run-tests --print-failures 35 exit 1 36 fi 37 38 PYTHONPATH=. python examples/test_udecimal.py > test_udecimal.exp 39 echo "=== Build CircuitPython bundle" 40 circuitpython-build-bundles --package_folder_prefix jepler --filename_prefix $repo_name --library_location . 41 42 echo "=== Build docs" 43 rm -rf docs/_build 44 (cd docs && sphinx-build -E -W -b html . _build/html) 45 46 echo "=== Build pypi files" 47 python setup.py sdist 48 python setup.py bdist_wheel --universal 49 50 echo "=== Check pypi files" 51 twine check dist/* 52 # SPDX-FileCopyrightText: Copyright (c) 2020 jepler for Unpythonic Networks 53 # 54 # SPDX-License-Identifier: MIT