This uses ccmake. Vanilla cmake can also be used
-
Activate your virtualenv:
source /path/to/env/bin/activate
-
Run ccmake configure as usual:
cd path/to/shogun
mkdir build
cd build
ccmake ..
Press c
to configure
-
In ccmake set
CMAKE_INSTALL_PREFIX
to point to your virtual environment:/path/to/env/local
-
Turn PythonModular
ON
and hit configure again -
Make sure the
PYTHON_EXECUTABLE
is pointing to the right python (presst
in ccmake to see all options). I.e./path/to/env/bin/python
- ON macOS: cmake may have trouble finding the right
PYTHON_LIBRARY
andPYTHON_INCLUDE_DIR
. You may therefore have to set them manually. - Make sure that
PYTHON_INCLUDE_DIR
points to your virtualenv, e.g./path/to/env/include/python2.7
. - Make sure that
PYTHON_LIBRARY
points to thelibpythonX.Y.dylib
corresponding to the python that your virtualenv was set up with (either the default virtualenv python or the python supplied withvirtualenv --python=/path/to/python
). You can check what the default python is by runningvirtualenv --help
- it will be listed in the description of the--python=
flag. Once you have established where the correct python is located, make sure thatPYTHON_LIBRARY
points to the correspondinglibpythonX.Y.dylib
, e.g./usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib
.
- ON macOS: cmake may have trouble finding the right
-
Now press
g
to generate and runmake install
-
If this goes well, you now need to configure the
$LD_LIBRARY_PATH
(on macOS$DYLD_LIBRARY_PATH
) environment variable to be configured correctly when you activate the virtual environment. This can be done by modifying theactivate
script of your virtual environment. Change/path/to/env/bin/activate
file to include the following:
...
deactivate () {
...
if [ -z "$_OLD_LD_LIBRARY_PATH" ] ; then
export LD_LIBRARY_PATH="$_OLD_LD_LIBRARY_PATH"
unset _OLD_LD_LIBRARY_PATH
fi
...
}
...
_OLD_LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH=/path/to/env/local/lib
...
-
Now
deactivate
your virtual environment and re-activate
it. Test that it is working by runningimport modshogun
in Python.- If you get the error
ImportError: libshogun.so.17: cannot open shared object file: No such file or directory
, then trysudo ldconfig
- If you get the error
g++ -I /path/to/virtualenv/local -lshogun examples/meta/cpp/binary/kernel_support_vector_machine.cpp -std=c++14