-
Notifications
You must be signed in to change notification settings - Fork 353
/
pyenv-linux-create.sh
executable file
·90 lines (67 loc) · 2.94 KB
/
pyenv-linux-create.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
#!/usr/bin/env bash
#echo "usage: ./${0##*/} <env-name>"
STARTING_DIR=`pwd`
export ENV_NAME=$1
if [[ -z "${ENV_NAME}" ]]; then
ENV_NAME='pyslam'
fi
ENVS_PATH=~/.python/venvs # path where to group virtual environments
ENV_PATH=$ENVS_PATH/$ENV_NAME # path of the virtual environment we are creating
# ====================================================
# import the utils
. bash_utils.sh
# ====================================================
version=$(lsb_release -a 2>&1) # ubuntu version
sudo apt update
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev unzip
sudo apt-get install -y libavcodec-dev libavformat-dev libavutil-dev libpostproc-dev libswscale-dev ffmpeg
sudo apt-get install -y libgtk2.0-dev
sudo apt-get install -y libglew-dev
sudo apt-get install -y libsuitesparse-dev
# https://github.com/pyenv/pyenv/issues/1889
export CUSTOM_CC_OPTIONS=""
if [[ $version == *"22.04"* ]] ; then
sudo apt install -y clang
fi
# install required package to create virtual environment
install_package python3-venv
. install_pyenv.sh
# create folder for virutal environment and get into it
make_dir $ENV_PATH
cd $ENVS_PATH
#export PYSLAM_PYTHON_VERSION="3.6.9"
export PYSLAM_PYTHON_VERSION="3.8.10"
# actually create the virtual environment
if [ ! -d $ENV_PATH/bin ]; then
export PATH="/home/$USER/.pyenv/bin:$PATH" # this seems to be needed under docker (even if it seems redundant)
print_blue creating virtual environment $ENV_NAME with python version $PYSLAM_PYTHON_VERSION
if [[ $version == *"22.04"* ]] ; then
CC=clang pyenv install -v $PYSLAM_PYTHON_VERSION
else
pyenv install -v $PYSLAM_PYTHON_VERSION
fi
pyenv local $PYSLAM_PYTHON_VERSION
python3 -m venv $ENV_NAME
fi
# activate the environment
cd $STARTING_DIR
export PYTHONPATH="" # clean python path => for me, remove ROS stuff
source $ENV_PATH/bin/activate
pip3 install --upgrade pip setuptools wheel --no-cache-dir
if [ -d ~/.cache/pip/selfcheck ]; then
rm -r ~/.cache/pip/selfcheck/
fi
print_blue "installing opencv"
PRE_OPTION="--pre" # this sometimes helps because a pre-release version of the package might have a wheel available for our version of Python.
MAKEFLAGS_OPTION="-j$(nproc)"
CMAKE_ARGS_OPTION="-DOPENCV_ENABLE_NONFREE=ON" # install nonfree modules
MAKEFLAGS="$MAKEFLAGS_OPTION" CMAKE_ARGS="$CMAKE_ARGS_OPTION" pip3 install opencv-python -vvv $PRE_OPTION
MAKEFLAGS="$MAKEFLAGS_OPTION" CMAKE_ARGS="$CMAKE_ARGS_OPTION" pip3 install opencv-contrib-python -vvv $PRE_OPTION
# install required packages (basic packages, some unresolved conflicts may be resolved by the next steps)
MAKEFLAGS="$MAKEFLAGS_OPTION" pip3 install -r requirements-pip3.txt #-vvv
# To activate the virtual environment run:
# $ source pyenv-activate.sh
# To deactivate run:
# $ deactivate