-1

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>
sinoroc
  • 18,409
  • 2
  • 39
  • 70
Chaitanya Bapat
  • 3,381
  • 6
  • 34
  • 59
  • 2
    I am wondering about the why of that question. Especially why the focus on wheel. Isn't it the same with any other distribution format? Or simply with `python setup.py install` for example? – sinoroc Jan 09 '21 at 10:06
  • _why do the *.so files get installed in site-package folder_? Because this is what you specified in the setup script. – hoefling Jan 09 '21 at 16:02
  • in the setup script i didnt mention anything specific for the *.so files. In other words, why doesn't the *.so files get packaged inside the library instead of outside? – Chaitanya Bapat Jan 09 '21 at 17:39
  • Would you rather the `lib*.so` files be installed inside the packages? – sinoroc Jan 09 '21 at 21:33
  • what's the recommendation for location for storing .so files related to a package? i saw pytorch *.so files within the torch directory inside site-packages. So i'd assume *.so files related to a package should be inside the package rather than site-packages. is there any recommendation? – Chaitanya Bapat Jan 09 '21 at 22:01
  • You should ask new questions. – sinoroc Jan 10 '21 at 08:14
  • which new questions? can you give example? – Chaitanya Bapat Jan 10 '21 at 20:34
  • For example: "How should C/C++ shared libraries be packaged (with setuptools)?" – sinoroc Jan 10 '21 at 20:49
  • _in the setup script i didnt mention anything specific for the *.so files._ - this is specified via extension name; e.g `ext_modules=[Extension("foo.bar.baz", ...)]` will place `baz.cpython-XY-platform.so` into `site-packages/foo/bar`, assuming the package `foo.bar` exists and is included in the distribution. – hoefling Jan 11 '21 at 14:12

1 Answers1

0

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.

Chaitanya Bapat
  • 3,381
  • 6
  • 34
  • 59