[LAD] installing python extensions

Marc Lavallée marc at hacklava.net
Mon Aug 15 16:54:06 CEST 2022


Hi Fons,

Christopher Arndt sent a long and detailed answer, here's a shorter one.

Python packages can be installed in user's home or virtual environments.
For example, to install the zita tools in my home environment, I cd to 
the zita-audiotools-1.3.0 directory, then used:
pip install .

Installation was successful, so I used the same method for zita-jacktools.
It includes the .so modules:
ls $HOME/.local/lib/python3.*/site-packages/zita_*tools/

For completion I uninstalled the packages in my home:
pip uninstall zita-audiotools zita-jacktools
Then I deleted the makefiles and reinstalled the packages (using same 
method).

I also reinstalled them globally using:
sudo pip install .
It worked too:
ls /usr/local/lib/python3.*/dist-packages/zita_*tools/*

There's newer configuration methods, but for now there's no need to 
update your packages, apart from removing the makefiles (and update the 
documentation).

Marc

Le 2022-08-15 à 08 h 30, Fons Adriaensen a écrit :
> 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,
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.linuxaudio.org/archives/linux-audio-dev/attachments/20220815/fb72302b/attachment.html>


More information about the Linux-audio-dev mailing list