Python setup.py apt install

setup.py can install prerequisites using apt install. However, this is quite risky. We strongly recommend instead using install_requires of setup.cfg.

Example

This process is not normally recommended, as most popular Python packages that require compiling have .whl binary wheel.

An example setup.py:

from setuptools import setup
import subprocess

install_requires = ['numpy','scipy']

req = [f'python3-{r}' for r in install_requires]

cmd = ['sudo','apt-get','install'] + req
print(' '.join(cmd))
subprocess.run(cmd)

setup()