Skip to content

Commit

Permalink
update install scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
luigifreda committed Jun 9, 2020
1 parent dd2de68 commit 7bcc7f7
Show file tree
Hide file tree
Showing 22 changed files with 295 additions and 48 deletions.
10 changes: 9 additions & 1 deletion CONDA.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,19 @@ Now, you can launch pySLAM scripts.

## Deactivate `pyslam` conda environment

To deactivate the `pyslam` environment, use
To deactivate the `pyslam` environment, run
```
$ conda deactivate
```

## Delete `pyslam` conda environment

To delete the `pyslam` environment, run
```
$ . pyenv-conda-delete.sh
```


---
# General Notes About Conda

Expand Down
33 changes: 32 additions & 1 deletion PYTHON-VIRTUAL-ENVS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
# pySLAM2 Virtual Environment

The following instructions allow you to create a custom `pyslam` virtual environment by using the package `python3-venv`. You will be able to run pyslam scripts within such environment.

## Basic Installation

In order to run `main_vo.py` with venv, get in the root of this repository and run the following command:
```
$ . pyenv-create.sh
```
**N.B.**: do not forget the dot! (without '/' !)

This will create a custom `pyslam` environment and will also activate it.

## Full Installation

In order to run `main_slam.py` with venv, get in the root of this repository and run the following command:
```
$ . install_all_venv.sh
```
**N.B.**: do not forget the dot! (without '/' !)

This will compile the required thirdparty packages and will also activate the created `pyslam` environment.



## Create a `pyslam` python virtual environment

In order to create a custom `pyslam` python virtual environment, get in the root of this repository and run the following command:
You already see this above. In order to create a custom `pyslam` python virtual environment, get in the root of this repository and run the following command:
```
$ . pyenv-create.sh
```
Expand All @@ -25,6 +49,13 @@ Run the command:
$ deactivate
```

## Delete `pyslam` environment

To delete the `pyslam` environment, run
```
$ . pyenv-delete.sh
```


---
# General Notes About Python Virtual Environments
Expand Down
4 changes: 3 additions & 1 deletion TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ If you get an error message like
import g2o
ModuleNotFoundError: No module named 'g2o' error
```
it's very likely you have libraries compiled in a 'mixed' way. Then, try to clean everything with the script `clean.sh`, and follow the installation procedure again.
First of all, check if you have a compiled `thirdparty/g2opy/lib/g2o.cpython-*-linux-gnu.so`. If not, Did you use one of the install_all scripts? Depending on your selected working environment (native, conda, python3-venv), you need to launch its companion install_all script in order to actually install all the required libraries (including g2o). Please, read the install instruction in the main [README](./README.md) file.

On the other hand, if you already have a compiled `thirdparty/g2opy/lib/g2o.cpython-*-linux-gnu.so`, it's very likely you have libraries compiled in a 'mixed' way. Then, try to clean everything with the script `clean.sh`, and follow the installation procedure again (see the main [README](./README.md) file).

### Problems with ROS and OpenCV

Expand Down
16 changes: 13 additions & 3 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# clean thirdparty install and utils
# clean thirdparty install and compiled libraries

# ====================================================
# import the utils
Expand All @@ -14,7 +14,17 @@ print_blue "=================================================================="
print_blue "clearning thirdparty packages and utils..."

rm -Rf thirdparty/pangolin

rm -Rf thirdparty/g2opy
rm -Rf thirdparty/protoc # set by install_delf.sh

rm -Rf thirdparty/protoc # set by install_delf.sh

rm -Rf thirdparty/orbslam2_features/build
rm -Rf cpp/utils/build
rm -Rf thirdparty/orbslam2_features/lib

rm -Rf cpp/utils/build
rm -Rf cpp/utils/lib


# TODO
# clean downloaded models
13 changes: 12 additions & 1 deletion cpp/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ ENDIF()

set(CMAKE_CXX_STANDARD 11)

set(WITH_PYTHON_INTERP_CHECK OFF CACHE BOOL "Checking python interpreter") # to be activate when called within virtual python environment

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -march=native -fPIC -DNDEBUG")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -march=native -fPIC -DNDEBUG")

Expand All @@ -22,7 +24,16 @@ message(STATUS "opencv include: ${OpenCV_INCLUDE_DIRS}")
message(STATUS "opencv lib dirs: ${OpenCV_INSTALL_PATH}")
message(STATUS "opencv libs: ${OpenCV_LIBS}")

find_package(PythonLibs)

# the following 2 lines are added to correctly detect the python version
if(WITH_PYTHON_INTERP_CHECK)
message(STATUS "WITH_PYTHON_INTERP_CHECK: ${WITH_PYTHON_INTERP_CHECK}")
find_package(PythonInterp)
find_package(PythonLibs)
message(STATUS "PythonInterp: ${PythonInterp}")
message(STATUS "PythonLibs: ${PythonLibs}")
endif()


include_directories(
${PYTHON_INCLUDE_DIRS}
Expand Down
12 changes: 9 additions & 3 deletions cpp/utils/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ if [ ! -d $1 ]; then
fi
}

STARTING_DIR=`pwd`
# ====================================================
# check if we have external options
EXTERNAL_OPTION=$1
if [[ -n "$EXTERNAL_OPTION" ]]; then
echo "external option: $EXTERNAL_OPTION"
fi
# ====================================================

make_dir build
cd build
cmake ..
cmake .. $EXTERNAL_OPTION
make -j 4

cd $STARTING_DIR
cd ..
10 changes: 5 additions & 5 deletions install_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

#N.B: this install script allows you to run main_slam.py and all the scripts

set -e

# ====================================================
# import the utils
. bash_utils.sh

# ====================================================

set -e

# set up git submodules
./install_basic.sh
# install basic modules and set up git submodules
. install_basic.sh # use . in order to inherit python env configuration and possible other env vars

# build and install thirdparty
./install_thirdparty.sh
. install_thirdparty.sh # use . in order to inherit python env configuration and possible other env vars
12 changes: 9 additions & 3 deletions install_all_conda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,22 @@

# ====================================================

set -e
#set -e

# set up git submodules
./install_basic.sh 0 # the '0' is an option for skipping pip3 packages installation
. install_basic.sh 0 0 # the first '0' is an option for skipping pip3 packages installation (script install_pip3_packages.sh),
# the second '0' is for skipping the install_cpp.sh script therein (that will be called below)

# create a pyslam environment within conda and activate it
. pyenv-conda-create.sh

export WITH_PYTHON_INTERP_CHECK=ON # in order to detect the correct python interpreter

# build and install cpp stuff
. install_cpp.sh # use . in order to inherit python env configuration and other environment vars

# build and install thirdparty
. install_thirdparty.sh
. install_thirdparty.sh # use . in order to inherit python env configuration and other environment vars


# N.B.:
Expand Down
36 changes: 36 additions & 0 deletions install_all_venv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

#N.B: this install script allows you to run main_slam.py and all the scripts

# ====================================================
# import the utils
. bash_utils.sh

# ====================================================

#set -e

# set up git submodules
. install_basic.sh 0 0 # the first '0' is an option for skipping pip3 packages installation (script install_pip3_packages.sh),
# the second '0' is for skipping the install_cpp.sh script therein (that will be called below)

# create a pyslam environment within venv
. pyenv-create.sh

export WITH_PYTHON_INTERP_CHECK=ON # in order to detect the correct python interpreter

# build and install cpp stuff
. install_cpp.sh # use . in order to inherit python env configuration and other environment vars

# build and install thirdparty
. install_thirdparty.sh # use . in order to inherit python env configuration and other environment vars


# N.B.:
# if your run into troubles with opencv xfeatures2D/SIFT/SURF then run the following commands into your pyslam environment
# $ pip3 uninstall opencv-contrib-python
# $ pip3 install opencv-contrib-python==3.4.2.16

# HACK (this is actually run inside the created pyenv environment )
#pip uninstall opencv-contrib-python
#pip install opencv-contrib-python==3.4.2.16
26 changes: 19 additions & 7 deletions install_basic.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env bash

#N.B: this install script allows you to run main_vo.py and the test scripts
# echo "usage: ./${0##*/} <INSTALL_PIP3_PACKAGES>" # the argument is optional
# echo "usage: ./${0##*/} <INSTALL_PIP3_PACKAGES> <INSTALL_CPP>" # the arguments are optional

#set -e

# ====================================================
# import the utils
Expand All @@ -10,29 +12,39 @@
# ====================================================

export INSTALL_PIP3_PACKAGES=1 # install pip3 packages by default
if [ $# -eq 1 ]; then
if [ $# -ge 1 ]; then
# check optional argument
INSTALL_PIP3_PACKAGES=$1
echo INSTALL_PIP3_PACKAGES: $INSTALL_PIP3_PACKAGES
fi
# ====================================================

set -e
export INSTALL_CPP=1 # install cpp by default
if [ $# -ge 2 ]; then
# check optional argument
INSTALL_CPP=$2
echo INSTALL_CPP: $INSTALL_CPP
fi

# ====================================================

echo `pwd`

# install system packages
./install_system_packages.sh
. install_system_packages.sh # use . in order to inherit python env configuration

# install pip3 packages
# N.B.: install_pip3_packages script can be skipped if you intend to use a virtual python environment
if [ $INSTALL_PIP3_PACKAGES -eq 1 ]; then
echo 'installing pip3 packages'
./install_pip3_packages.sh
./install_pip3_packages.sh
fi

# set up git submodules
./install_git_modules.sh

# build and install cpp stuff
./install_cpp.sh
# N.B.: install_cpp script can be skipped here if you intend to use a virtual python environment
# but it must be then called within your virtual python environment in order to properly install libs
if [ $INSTALL_CPP -eq 1 ]; then
./install_cpp.sh
fi
24 changes: 21 additions & 3 deletions install_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,23 @@

# ====================================================

set -e
#set -e


# ====================================================
# check if we have external options
EXTERNAL_OPTION=$1
if [[ -n "$EXTERNAL_OPTION" ]]; then
echo "external option: $EXTERNAL_OPTION"
fi

# check if we want to add a python interpreter check
if [[ -n "$WITH_PYTHON_INTERP_CHECK" ]]; then
echo "WITH_PYTHON_INTERP_CHECK: $WITH_PYTHON_INTERP_CHECK "
EXTERNAL_OPTION="$EXTERNAL_OPTION -DWITH_PYTHON_INTERP_CHECK=$WITH_PYTHON_INTERP_CHECK"
fi
# ====================================================


print_blue '================================================'
print_blue "Building and installing cpp ..."
Expand All @@ -16,8 +32,10 @@ cd cpp

# build utils
cd utils
./build.sh
. build.sh $EXTERNAL_OPTION # use . in order to inherit python env configuration
cd ..

# ...
cd ..



2 changes: 1 addition & 1 deletion install_delf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
STARTING_DIR=`pwd` # this should be the main folder directory of the repo


set -e
#set -e

# N.B.: this must be run after having run the script install_git_modules.sh

Expand Down
5 changes: 3 additions & 2 deletions install_git_modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# ====================================================

set -e
#set -e


STARTING_DIR=`pwd` # this should be the main folder directory of the repo
Expand Down Expand Up @@ -76,4 +76,5 @@ cd $STARTING_DIR


# install delf
./install_delf.sh
./install_delf.sh
cd $STARTING_DIR
2 changes: 1 addition & 1 deletion install_pip3_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# ====================================================

set -e
#set -e

print_blue '================================================'
print_blue "Configuring and installing python packages ..."
Expand Down
2 changes: 1 addition & 1 deletion install_system_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# ====================================================

set -e
#set -e

print_blue '================================================'
print_blue "Configuring and installing system packages ..."
Expand Down
Loading

0 comments on commit 7bcc7f7

Please sign in to comment.