Search code examples
python-c-apipython-packagingpython-wheel

Why does wheel installation put shared objects in site-packages folder instead of package folder?


I've a python binary distribution [wheel] created via

python setup.py bdist_wheel

The wheel looks as follows

 unzip -l dist/<package-name>-1.0.0-cp36-cp36m-linux_x86_64.whl
Archive:  dist/<package-name>-1.0.0-cp36-cp36m-linux_x86_64.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
  2996432  2021-01-07 21:47   lib<xyz>.so
  7821608  2021-01-07 21:48   lib<abc>.so
  4414000  2021-01-07 21:48   <module>.cpython-36m-x86_64-linux-gnu.so
      581  2021-01-07 20:05   <package-name>/__init__.py
      636  2021-01-07 20:05   <package-name>/version.py

Upon installing the wheel, why do the *.so files get installed in site-package folder?

/opt/conda/lib/python3.6/site-packages/

While the other files get installed inside

/opt/conda/lib/python3.6/site-packages/<package-name>

Solution

  • Wheel is essentially a compressed form of package distribution. Hence it can be unzipped [like a zip file]. The entire directory structure inside the zipped wheel gets copied as is in the site-packages folder. This is the reason why

    1. the shared libraries are stored inside site-packages and
    2. rest of the package files [e.g. __init__.py are stored inside the package subfolder of the site-packages].

    wheel gets unzipped in the site-packages folder essentially.