8

I'm trying to learn pybind11 and the first Google result is this page, where you should be guided towards compiling and running some test cases. From this page, I have installed bybind11 by:

pip3 install pybind11

and I have installed:

sudo apt install python3-dev cmake

as instructed in the original page. But I don't know how to go to the next step which is to

mkdir build ...

and the rest of the steps to compile the test cases. I suppose this should be inside the pybind11 installation folder installed via pip3.

my environment is:

  • Ubuntu 18.04.3 LTS bionic
  • Python3 3.6.9
  • pip 20.0.2

and my questions are:

  • where is the path to the presumed test cases where I can follow the rest of the tutorial from
  • is this the correct/best way to install pybind11? if not what is the recommended method of installation?

P.S.1. using pip3 show pybind11 I realized that I have version 2.4.3 installed and the installation folder is /usr/<userName>/.local/lib/python3.6/sitepackages. However, inside the pybind11 folder there are no test cases as far as I can see.

P.S.2. From here I installed via sudo apt install python-pybind11 and from here using dpkg --listfiles python-pybind11 I found the installation folder at /usr/lib/python2.7/dist-packages/. Not only there are no test cases in this folder either, but this is also python2.7 which I don't want to use!

Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193

1 Answers1

6

You need to install pybind11 as instructed here by cloning the GitHub repository:

python3 -m pip install pytest numpy scipy
sudo apt install -y cmake python3-dev libeigen3-dev libboost-dev git
git clone https://github.com/pybind/pybind11.git
cd pybind11
cmake -DDOWNLOAD_CATCH=1
mkdir build
cd build
cmake ..
sudo make install
cd ..

Then you can run the tests by going to the folder cd tests. Next, follow steps in the tutorial, starting with mkdir build.

P.S. You may also need to make sure your Python packages are up to date, following the instructions here.

Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193
NicholasM
  • 4,557
  • 1
  • 20
  • 47
  • this is the correct answer. thanks. but I think you need to install it first as instructed [here](https://stackoverflow.com/a/56552686/4999991). – Foad S. Farimani Jan 27 '20 at 21:20
  • 1
    It should be possible to build and run the tests after installing the prerequisites like `cmake` and `pytest`. In order to build the tests in the repository, it should not be necessary to install `pybind11` itself using a package manager. – NicholasM Jan 27 '20 at 21:31
  • I applied some edits, but they are implemented anyway. I hope you are ok with them? – Foad S. Farimani Jan 27 '20 at 21:41