[LAD] installing python extensions

Fons Adriaensen fons at linuxaudio.org
Mon Aug 15 14:30:02 CEST 2022


Hello all,

I have some mixed python/C++ packages, e.g. zita-audiotools
and zita-jacktools.

To install these I expect the following to happen:

1. The C++ parts are compiled and combined into a *.so
   file which is a python extension.
2. The *.so and the python parts, any data etc. get
   installed into the user's /usr/lib/python*.*/site-packages.

To make this as easy as possible I provide a setup.py and a 
Makefile, so that all that should be required is:

make; sudo make install

Originally this used distutils, when that got 'deprecated'
this changed to setuptools. So until recently the Makefile
was something like: 

----
PY = /usr/bin/python3

build:
    $(PY) ./setup.py build

install:
    $(PY) ./setup.py install

clean:
    $(PY) ./setup.py clean
    rm -rf build dist zita_jacktools.egg-info
---

Then I got warnings telling me that calling setup.py directly
is now  also deprecated, and that I should use 'official tools'
to build and install. What exactly that means I was unable to
find out, but the following seems to work:

----
PY = /usr/bin/python3

build:
    $(PY) -m build -w

install:
    pip install --force-reinstall dist/*.whl

clean:
    rm -rf build dist *.egg-info *~
----

But this still produces a warning:

> WARNING: Running pip as the 'root' user can result in broken
> permissions and conflicting behaviour with the system package
> manager. It is recommended to use a virtual environment instead.

Now clearly installing things in site-packages requires root,
so what is then the recommended method ?? And why the virtual
environment (which is used by build anyway) ??

If anyone can shed some light on this mess he/she will deserve
my eternal gratitude.

Ciao,

-- 
FA




More information about the Linux-audio-dev mailing list