Python setup.py install requirements.txt

less than 1 minute read

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

install_requires = ['numpy','scipy']  # long pip install time since no .whl for ARM
from setuptools import setup, find_packages
import subprocess
import sys,os

req = [os.path.basename(sys.executable) + '-' + r for r in install_requires]

try:
    cmd = ['sudo','apt-get','install'] + req
    print(' '.join(cmd))
    subprocess.check_call(cmd)
    ok=True
except Exception as e:
    ok = False
    print(e)

setup(name='cool_program',
      packages=find_packages(),
      install_requires=install_requires,
      )

if not ok:
    print('\n *** please execute')
    print(' '.join(cmd))

Leave a comment