Last active
April 22, 2021 19:41
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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