pybind / python_example

Example pybind11 module built with a Python-based build system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

python-example installs pybind11 too late

mglisse opened this issue · comments

Trying to build python-example on a machine where pybind11 is not installed yet, it does install pybind11 automatically and provides the right path to find the headers of an installed pybind11 (I patched setup.py to print them with "INCLUDE:", don't be surprised by them), except that the headers are not there yet when the compiler runs, setup_requires only put them in some /tmp/pip-install-*. After the error, they do move to their expected place ("Installing collected packages: pybind11"), but it is too late. Running the same command when pybind11 is already installed (for instance by the previous failed attempt) works fine.
Unless you can convince pip to really install packages before setup, I think it means the logic used to give the path to the headers needs some refinement.

/tmp $ pip3 install ./python_example                     
Processing ./python_example
Collecting pybind11>=2.4 (from python-example==0.0.1)
  Using cached https://files.pythonhosted.org/packages/4b/4d/ae1c4d8e8b139afa9682054dd42df3b0e3b5c1731287933021b9fd7e9cc4/pybind11-2.4.3-py2.py3-none-any.whl
Building wheels for collected packages: python-example
  Running setup.py bdist_wheel for python-example ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-req-build-bi9gmv5j/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-sqdhu1u6 --python-tag cp37:
  running bdist_wheel
  running build
  running build_ext
  creating tmp
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.7m -c /tmp/tmp41p70shh.cpp -o tmp/tmp41p70shh.o -std=c++17
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.7m -c /tmp/tmp5oeoq218.cpp -o tmp/tmp5oeoq218.o -fvisibility=hidden
  building 'python_example' extension
  INCLUDE:  /usr/local/include/python3.7
  INCLUDE:  /home/glisse/.local/include/python3.7m
  creating build
  creating build/temp.linux-x86_64-3.7
  creating build/temp.linux-x86_64-3.7/src
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/local/include/python3.7 -I/home/glisse/.local/include/python3.7m -I/usr/include/python3.7m -c src/main.cpp -o build/temp.linux-x86_64-3.7/src/main.o -DVERSION_INFO="0.0.1" -std=c++17 -fvisibility=hidden
  src/main.cpp:1:10: fatal error: pybind11/pybind11.h: No such file or directory
      1 | #include 
        |          ^~~~~~~~~~~~~~~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for python-example
  Running setup.py clean for python-example
Failed to build python-example
Installing collected packages: pybind11, python-example
  Running setup.py install for python-example ... done
Successfully installed pybind11-2.4.3 python-example-0.0.1

This should be fixed now. cc @wjakob