-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·92 lines (76 loc) · 1.64 KB
/
install.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
#!/bin/env sh
thisdir=$(realpath $(dirname $0))
# cloning pyenv
DUSTDIR=${thisdir}/dustenv
PYENVDIR=${DUSTDIR}/pyenv
REPOSRC=https://github.com/pyenv/pyenv.git
git clone "$REPOSRC" "$PYENVDIR" 2> /dev/null || git -C "$PYENVDIR" pull
# run setup script
. ${DUSTDIR}/pyenv-source.sh
# import utilities
. ${DUSTDIR}/common.sh
if test "$1" = "list"
then
pyenv install -l
exit
fi
# install the python version
version=$1
if test -z $version
then
if test ! -f ${thisdir}/.python-version
then
echo "Please, provide the Python version to be installed!"
exit
fi
version=$(cat ${thisdir}/.python-version)
fi
# install dependencies
. ${DUSTDIR}/dependencies.sh
if ! install_python_dust_dependencies
then
echo -n "Python dependencies were not installed correctly. Do you want to continue anyway? [y/n] "
read -r option
if test $option != "y" && test $option != "Y"
then
exit
fi
fi
working_dir=$(pwd)
cd $thisdir
pyenv install $1
# set python version
pyenv local $1
# upgrade pip
pyenv exec python -m pip install -U pip
# install pdm
pyenv exec python -m pip install -U pdm
# select python version for pdm
pyenv exec pdm use $(pyenv which python)
# install build dependencies
if test ! -f "pyproject.toml"
then
pyenv exec pdm init --python $(pyenv prefix)/bin/python
fi
dust_sync
# create .venv link
if test ! -e ".venv"
then
ln -s $(pyenv prefix) .venv
fi
# installation check
echo "-------------------"
echo "-------------------"
echo "Installation Check:"
found_python=$(pyenv exec which python)
case "$found_python" in
$(realpath $PYENVDIR)*)
echo "OK!"
exit 0
;;
*)
echo "ERROR!"
exit 1
;;
esac
cd $pwd