yingjerkao / uni10

Official Repo for Uni10
28 stars 9 forks source link

Ability to specify python path #25

Closed macthecadillac closed 7 years ago

macthecadillac commented 7 years ago

Hi,

I was trying to compile this library and use it with Anaconda python (python 3) instead of my distribution's python. I'm wondering if there is a way to specify my python path at compile time with BUILD_PYTHON_WRAPPER set to be true. I looked at the CMakesLists.txt and there doesn't seem to be an option for that. I also tried specifying my $PYTHONPATH variable in the shell but the cmake summary still shows the system python path. Please point me to the make option if I indeed overlooked such an option.

Thanks.

yingjerkao commented 7 years ago

For future reference. You can specify the python executable, header and library using -D PYTHON_EXECUTABLE=<PATH to your python exe>, -D PYTHON_INCLUDE_DIR=<PATH to Python.h> and -D PYTHON_LIBRARY=<PATH to libpython>

You need to delete CmakeCache.txt in your build directory before you redo cmake.

macthecadillac commented 7 years ago

Thanks. I just got it figured out.

macthecadillac commented 7 years ago

This is what I did in the end:

$ export CXX="$HOME/intel/bin/icpc"
$ export CC="$HOME/intel/bin/icc"
$ cmake -DCMAKE_INSTALL_PREFIX=$HOME/.local/uni10 \
        -DBUILD_WITH_MKL=on \
        -DCMAKE_CXX_FLAGS:STRING=-I$HOME/anaconda3/include/python3.6m \
        -DCMAKE_C_FLAGS:STRING=-I$HOME/anaconda3/include/python3.6m \
        -DBUILD_PYTHON_WRAPPER=on \
        -DPYTHON_EXECUTABLE=$HOME/anaconda3/bin/python \
        -DPYTHON_INCLUDE_DIR=$HOME/anaconda3/include/python3.6m \
        -DPYTHON_LIBRARY=$HOME/anaconda3/lib/libpython3.so \
        -DBUILD_DOC=on ../uni10/

Then make -j4

It is also worth noting that after make install you'll need to manually install the python interface by navigating into ./pyUni10 and do python setup.py install