From 840430c484ede42a4344c313d5836d0da7336d39 Mon Sep 17 00:00:00 2001 From: Hannes Feldt <feldt@astron.nl> Date: Tue, 11 Mar 2025 15:08:45 +0100 Subject: [PATCH] add setup.sh --- {{cookiecutter.project_slug}}/setup.sh | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 {{cookiecutter.project_slug}}/setup.sh diff --git a/{{cookiecutter.project_slug}}/setup.sh b/{{cookiecutter.project_slug}}/setup.sh new file mode 100755 index 0000000..4548910 --- /dev/null +++ b/{{cookiecutter.project_slug}}/setup.sh @@ -0,0 +1,30 @@ +#! /usr/bin/env bash +# +# Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy) +# SPDX-License-Identifier: Apache-2.0 +# + +# This file's directory is used to determine the station control directory +# location. +if [ -z ${BASH_SOURCE} ]; then + BASH_SOURCE=${(%):-%x} +fi + +ABSOLUTE_PATH=$(realpath $(dirname ${BASH_SOURCE})) + +# Create a virtual environment directory if it doesn't exist +VENV_DIR="${ABSOLUTE_PATH}/.venv" +if [ ! -d "$VENV_DIR" ]; then + echo "Creating virtual environment..." + python3 -m venv "$VENV_DIR" +fi + +# Activate the virtual environment +source "$VENV_DIR/bin/activate" +python -m pip install pre-commit +python -m pip install "tox>=4.21.0" + +# Install git pre-commit pre-push hook +if [ ! -f "${ABSOLUTE_PATH}/.git/hooks/pre-push.legacy" ]; then + source "${ABSOLUTE_PATH}/bin/install-hooks/pre-commit.sh" +fi -- GitLab