Skip to content

Instantly share code, notes, and snippets.

@scivision
Last active April 22, 2021 19:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scivision/9e17779aafd63fea2471fb6b43a108f9 to your computer and use it in GitHub Desktop.
Save scivision/9e17779aafd63fea2471fb6b43a108f9 to your computer and use it in GitHub Desktop.
Python setup.py that installs requirements.txt using apt-get install (useful for ARM systems like Raspberry Pi and Beaglebone without Anaconda Python)
#!/usr/bin/env python
from setuptools import setup
import subprocess
import sys,os
with open('requirements.txt', 'r') as f:
req = f.read().split('\n')
req = [os.path.basename(sys.executable) + '-' + r for r in req if r]
try:
cmd = ['sudo','apt-get','install'] + req
print(' '.join(cmd))
subprocess.check_call(cmd)
ok=True
except Exception as e:
ok = False
setup(name='cool_program',
packages=['cool_program'],
)
if not ok:
print('\n *** please execute')
print(' '.join(cmd))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment