control: retitle -1 python3.9: sysconfig should return /dist-packages as platlib

Hello,

Matthias Klose, le mer. 10 nov. 2021 14:53:38 +0100, a ecrit:
> On 11/7/21 13:53, Samuel Thibault wrote:
> >>>> sys.path
> > ['', '/usr/lib/python39.zip', '/usr/lib/python3.9', 
> > '/usr/lib/python3.9/lib-dynload', 
> > '/home/samy/.local/lib/python3.9/site-packages', 
> > '/usr/local/lib/python3.9/dist-packages', '/usr/lib/python3/dist-packages', 
> > '/usr/lib/python3.9/dist-packages']
> > 
> > We can see /usr/local/lib/python3.9/dist-packages, but AIUI,
> > 'dist-packages' is meant only for distribution-provided python packages,
> > which /usr/local is definitely not about. And indeed, when installing
> > some python library with the usual python3 setup.py build / install
> > process (e.g. from upstream speech-dispatcher source), the python
> > modules are going to /usr/local/lib/python3.9/site-packages, and not
> > dist-packages.
> > 
> > And thus the just-installed python modules are not getting found, and
> > people are confused since they did run python3 setup.py properly.
> > 
> > 
> > So it seems that sys.path should be fixed into:
> > 
> >>>> sys.path
> > ['', '/usr/lib/python39.zip', '/usr/lib/python3.9', 
> > '/usr/lib/python3.9/lib-dynload', 
> > '/home/samy/.local/lib/python3.9/site-packages', 
> > '/usr/local/lib/python3.9/site-packages', '/usr/lib/python3/dist-packages', 
> > '/usr/lib/python3.9/dist-packages']
> 
> The argument against /usr/local/lib/python3.9/site-packages is, that the very
> same location is used for a local python build with the default configure 
> flags,
> e.g. ./configure ...
> 
> That allows way too easy mixing of locally installed python modules.
> Having a /usr/local/lib/python3.9/dist-packages avoids that.

Ok, but the set of people who build their own python interpreter with
./configure is *way* smaller than the set of people who build some
$random_package which happens to use python. And people who build their
own python interpreter are the same who know a bit about such kind of
issues.

That being said, it's Debian which tells applications to
install modules built with the Debian python interpreter into
/usr/local/lib/python3.9/site-packages. The python.m4 snippet shipped by
automake uses:

   am_cv_python_pyexecdir=`$PYTHON -c "
$am_python_setup_sysconfig
if can_use_sysconfig:
  sitedir = sysconfig.get_path('platlib', 
vars={'platbase':'$am_py_exec_prefix'})
else:

i.e.

import sys
import sysconfig
sitedir = sysconfig.get_path('platlib', vars={'platbase':'/usr/local'})

which results to '/usr/local/lib/python3.9/site-packages'

Following your reasoning, sysconfig should return
/usr/local/lib/python3.9/dist-packages
instead of
/usr/local/lib/python3.9/site-packages

Samuel

Reply via email to