3

I am building a deb package from source. The source used to install the modules in 'site-packages' in RHEL.

On Ubuntu, 'site-packages' doesn't work for me. Searching over the net, it says that python Ubuntu would require it in 'dist-packages'

But there are also references that python built from source would look in 'site-packages'

Now I am confused, where should my deb packages install the modules so that it works irrespective of python built from source or installed from Ubuntu repo

mittal
  • 915
  • 10
  • 29
  • Possible duplicate of [What's the difference between dist-packages and site-packages?](https://stackoverflow.com/questions/9387928/whats-the-difference-between-dist-packages-and-site-packages) – sds Jun 27 '18 at 13:05

3 Answers3

12

dist-packages is a Debian convention that is present in distros based on Debian. When we install a package using the package manager like apt-get these packages are installed to dist-packages. Likewise, if you install using pip and pip is installed via package manager then these packages will be installed in dist-packages.

If you build python from source then pip comes with it, now if you install a package using this pip it'll be installed into site-packages.

So It depends on which python binary you are using if you are using the binary that comes from package manager it will search in dist-packages and if you are using a binary from manual install it'll search in site-packages.

Priyanshu Jain
  • 663
  • 10
  • 18
  • Yes, and my confusion was that I am building my own package which users would install. The package would not be compliant with both kind of python installations. So where should the package install the binaries into. And it turns out that I have to choose only 1 of them that is 'dist-packages' assuming that python was installed from Ubuntu repo – mittal Nov 27 '17 at 12:32
0

From what I learnt from IRC is that I should install the modules in 'dist-packages' only, assuming that the admin would have installed the python provided by Ubuntu repo only.

mittal
  • 915
  • 10
  • 29
0

There is a "purelib" and a "platlib" directory. You can find out what they are by running:

$ python -c "import sysconfig; print sysconfig.get_paths()['purelib']"

$ python -c "import sysconfig; print sysconfig.get_paths()['platlib']"

Note however that by doing this you already select a certain python installation. As said above, the exact path depends on the installation.

Walter
  • 803
  • 6
  • 7
  • This does not return the correct result on Ubuntu/Debian (whereas the deprecated `distutils.sysconfig` module does). – rdb Nov 18 '22 at 17:34