diff --git a/bin/activate-venv b/bin/activate-venv new file mode 100755 index 0000000..84dcde8 --- /dev/null +++ b/bin/activate-venv @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +activate-venv() { + if [[ -f ".venv/bin/activate" ]]; then + source ".venv/bin/activate" + else + echo "Could not find .venv/bin/active" + echo "Init venv with $(uv --version)" + uv venv + fi +} \ No newline at end of file diff --git a/bin/init-venv b/bin/init-venv deleted file mode 100755 index e5bc1da..0000000 --- a/bin/init-venv +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -init-venv() { - if [[ ! -d "venv$GIT_BRANCH" ]]; then - echo "Create virtualenv venv$GIT_BRANCH." - uv venv "venv$GIT_BRANCH" - fi -} - -activate-venv() { - echo "Source virtualenv venv$GIT_BRANCH." - source "venv$GIT_BRANCH/bin/activate" -} \ No newline at end of file diff --git a/library.md b/library.md index 9e636c7..42546c5 100644 --- a/library.md +++ b/library.md @@ -50,16 +50,10 @@ printf "$column" "template-dotenv" "" "Generate .env from .env.template." ## Python -Set git env vars. +### activate-venv ```bash -GIT_BRANCH=$(git symbolic-ref --short -q HEAD) -``` - -### init-venv - -```bash -printf "$column" "init-venv" "" "Initialize and activate Python virtual env." +printf "$column" "activate-venv" "" "Activate or initialize Python virtual env." ``` ## Environment diff --git a/patterns.md b/patterns.md index 5346bd7..a34865e 100644 --- a/patterns.md +++ b/patterns.md @@ -84,10 +84,10 @@ Activate the virtual env. ```bash activate-venv() { - if [[ -f ".venv$ODOO_VERSION/bin/activate" ]]; then - source ".venv$ODOO_VERSION/bin/activate" + if [[ -f ".venv/bin/activate" ]]; then + source ".venv/bin/activate" else - echo "Could not find .venv$ODOO_VERSION/bin/active. Use init-venv to initalize." + echo "Could not find .venv/bin/active. Use init-venv to initalize." fi } ```