-
Notifications
You must be signed in to change notification settings - Fork 96
/
pypy_venv.sh
executable file
·100 lines (86 loc) · 2.68 KB
/
pypy_venv.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bash
set -e
NAME=$1
DIR=$(dirname $0)
cd $DIR
#sudo apt-get install cmake libreadline-dev
if [ -z "$NAME" ]; then
echo "use this script with ./pypy_venv <NAME>"
exit
fi
# setup
mkdir -p pypy
cd pypy
if [ -f "/etc/NIXOS" ]; then
echo "This is NixOS, using pypy from nix-shell"
set +e
source $(command -v virtualenvwrapper.sh)
mkvirtualenv -p $(command -v pypy3) $NAME
set -e
echo "installed pypy in $NAME"
exit 0
elif [ -f "/etc/arch-release" ]; then
echo "This is an arch distro"
ARCH=$(uname -m)
SUBVERSION=$(pacman -Si pypy3 | grep "Version\s*:\s*[0-9.\-]*" | grep -o "[0-9.\-]*")
VERSION=${2-pypy3-$SUBVERSION-$ARCH}
# get pypy
[ ! -e $VERSION.pkg.tar.zst ] && wget https://mirrors.kernel.org/archlinux/community/os/$ARCH/$VERSION.pkg.tar.zst
if [ ! -e $VERSION ]; then
tar xf $VERSION.pkg.tar.zst
mv ./opt/pypy3 ./$VERSION
fi
set +e
source /usr/bin/virtualenvwrapper.sh
set -e
else
if [ "$(uname)" == "Darwin" ]; then PYPY_OS=osx64; else PYPY_OS=linux64; fi
DOWNLOAD_URL=$(wget -q -O - https://www.pypy.org/download.html | egrep -o 'https://downloads.python.org/pypy/pypy3[^"]+' | grep "$PYPY_OS" | head -n 1)
# get pypy
wget $DOWNLOAD_URL --local-encoding=utf-8 -O - | tar xj
if [ -e /etc/pacman.conf ]
then
set +e
source /usr/bin/virtualenvwrapper.sh >>$OUTFILE 2>>$ERRFILE
set -e
elif [ -e /etc/fedora-release ]
then
set +e
source /usr/bin/virtualenvwrapper-3.sh
set -e
elif [ -e /etc/NIXOS ]
then
set +e
source $(command -v virtualenvwrapper.sh)
set -e
else
python3 -m pip install virtualenvwrapper
set +e
if [ -f /etc/bash_completion.d/virtualenvwrapper ]
then
source /etc/bash_completion.d/virtualenvwrapper
elif [ -f /usr/local/bin/virtualenvwrapper.sh ]
then
export VIRTUALENVWRAPPER_PYTHON=$(which python3)
source /usr/local/bin/virtualenvwrapper.sh
elif [ -f "$HOME/.local/bin/virtualenvwrapper.sh" ]
then
export VIRTUALENVWRAPPER_PYTHON=$(which python3)
source "$HOME/.local/bin/virtualenvwrapper.sh"
elif [ -f /usr/share/virtualenvwrapper/virtualenvwrapper.sh ]
then
export VIRTUALENVWRAPPER_PYTHON=$(which python3)
source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
fi
set -e
fi
fi
# virtualenv
set +e
pypy3_=$(find ${PWD} -maxdepth 1 -type d -name "pypy3*")
mkvirtualenv --no-pip -p ${pypy3_}/bin/pypy3 $NAME
python -m ensurepip
set -e
python -m pip install -U setuptools
echo "installed pypy in $NAME"
exit 0