Skip to content

Instantly share code, notes, and snippets.

@jtmoon79
Last active July 20, 2022 22:46
Show Gist options
  • Save jtmoon79/081b2509d4d878fd18043979d2e4b22e to your computer and use it in GitHub Desktop.
Save jtmoon79/081b2509d4d878fd18043979d2e4b22e to your computer and use it in GitHub Desktop.
Python virtualenv create
#!/usr/bin/env bash
#
# helper to quickly create a Python virtualenv
# latest at https://github.com/jtmoon79/dotfiles/blob/master/utilities/venv-create.sh
set -eu
# XXX: not very portable
source /etc/os-release
(
set -x
${PYTHON-python3} --version
)
V_=${1-".venv-$(${PYTHON-python3} --version | cut -f2 -d ' ')-${ID}-${VERSION_ID}"}
path=$(realpath "./${V_}" || true)
set -x
exec ${PYTHON-python3} -m venv --copies --prompt "${path}" "${path}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment