From 6d7749f823feea4bf70170c3b6b93c85d03f798b Mon Sep 17 00:00:00 2001 From: JohnTheCoolingFan Date: Sun, 1 Dec 2024 03:45:15 +0300 Subject: [PATCH] python: Add variant of mkv command with system site packages Sometimes it's useful to include system site packages and use virtual environments to add additional packages without touching system site. --- plugins/python/python.plugin.zsh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/python/python.plugin.zsh b/plugins/python/python.plugin.zsh index 63733e1de..d00005126 100644 --- a/plugins/python/python.plugin.zsh +++ b/plugins/python/python.plugin.zsh @@ -81,6 +81,18 @@ function mkv() { vrun "${name}" } +# Create a new virtual environment using the specified name. +# If none specified, use $PYTHON_VENV_NAME +# Use system site packages +function mkvs() { + local name="${1:-$PYTHON_VENV_NAME}" + local venvpath="${name:P}" + + python3 -m venv --system-site-packages "${name}" || return + echo >&2 "Created venv with system site packages in '${venvpath}'" + vrun "${name}" +} + if [[ "$PYTHON_AUTO_VRUN" == "true" ]]; then # Automatically activate venv when changing dir function auto_vrun() {