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.
This commit is contained in:
JohnTheCoolingFan 2024-12-01 03:45:15 +03:00
commit 6d7749f823
No known key found for this signature in database
GPG key ID: BCDF5D19503396FD

View file

@ -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() {