Skip to content

Instantly share code, notes, and snippets.

@goneri
Created September 6, 2019 22:14
Show Gist options
  • Save goneri/1fd2a326361a9fe1f757b7371ab511fa to your computer and use it in GitHub Desktop.
Save goneri/1fd2a326361a9fe1f757b7371ab511fa to your computer and use it in GitHub Desktop.
#!/bin/bash
function test_venv() {
cmd=$1
venv_dir=$(mktemp -d)
tmp_dir=$(mktemp -d)
if ! $cmd ${venv_dir} > /dev/null 2>&1; then
return
fi
ln -s ${venv_dir}/bin/python ${tmp_dir}/python
if [ ! "$(${tmp_dir}/python -c 'import sys; print(sys.path)'|grep ${venv_dir})" ]; then
echo "$cmd: venv lost"
else
echo "$cmd: venv ok"
fi
}
uname -a
test_venv 'python3.6 -m venv'
test_venv 'python3.7 -m venv'
test_venv 'virtualenv-2'
test_venv 'virtualenv -p python3.6'
test_venv 'virtualenv -p python2.7'
test_venv 'virtualenv -p python3.7'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment