Pip succeeds whereas setup.py fails

I’ve just found a funny case with a package, pyv4l2, where setup.py build failed to build it, but pip is magically successful.

This is how I built with setup.py:

$ python3.6 setup.py build
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/pyv4l2
copying pyv4l2/exceptions.py -> build/lib.linux-x86_64-3.6/pyv4l2
copying pyv4l2/__init__.py -> build/lib.linux-x86_64-3.6/pyv4l2
running build_ext
building 'pyv4l2.frame' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/pyv4l2
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/quan/.pyenv/versions/3.6.12/include/python3.6m -c pyv4l2/frame.c -o build/temp.linux-x86_64-3.6/pyv4l2/frame.o
gcc: error: pyv4l2/frame.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
error: command 'gcc' failed with exit status 1

Here is pip:

$ python3.6 -m pip install pyv4l2
Collecting pyv4l2
  Using cached https://files.pythonhosted.org/packages/33/de/1f484ce034347d8900923d005e613d49531ec5f9cce48e810c3dff008e8d/pyv4l2-1.0.2.tar.gz
Installing collected packages: pyv4l2
  Running setup.py install for pyv4l2 ... done
Successfully installed pyv4l2-1.0.2

Could someone explain me why pip is successful in this case.

Did you run setup.py from the GitHub clone? It seems like the repo and sdist on PyPI contain different files. This is a common mistake—what you see on GitHub is usually different from what you download on PyPI.

I can run setup.py build successfully after pip download pyv4l2 and extract the .tar.gz manually.

Thanks, I run setup.py on the master branch. That’s why…