From 8538645ba0ff5a2ae470270edcb4936d7f8df787 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Tue, 18 Jun 2024 13:34:04 +0100 Subject: [PATCH] install.sh: check for and install requirements-examples.txt. --- boilerplate.md | 8 ++++++++ install.sh | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/boilerplate.md b/boilerplate.md index 254b724..995cb73 100644 --- a/boilerplate.md +++ b/boilerplate.md @@ -95,6 +95,14 @@ Press Ctrl+C to exit. """) ``` +If your examples need additional dependencies, then list them in: + +``` +requirements-examples.txt +``` + +Otherwise, just delete this file to avoid unecessarily prompting the user. + ## Install / Uninstall Scripts If your package directory (`PROJECT_NAME/`) differs from your library name, you should update `install.sh` and `uninstall.sh` and hard-code the correct library name. diff --git a/install.sh b/install.sh index 3db90bc..61f1a4a 100755 --- a/install.sh +++ b/install.sh @@ -166,6 +166,12 @@ function pip_pkg_install { check_for_error } +function pip_requirements_install { + # A null Keyring prevents pip stalling in the background + PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring $PYTHON -m pip install -r "$@" + check_for_error +} + while [[ $# -gt 0 ]]; do K="$1" case $K in @@ -335,6 +341,15 @@ fi printf "\n" +if [ -f "requirements-examples.txt" ]; then + if confirm "Would you like to install example dependencies?"; then + inform "Installing dependencies from requirements-examples.txt..." + pip_requirements_install requirements-examples.txt + fi +fi + +printf "\n" + # Use pdoc to generate basic documentation from the installed module if confirm "Would you like to generate documentation?"; then