-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
setup.py
49 lines (39 loc) · 1.6 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import venv
import os
import sys
import subprocess
import argparse
import shutil
ENV_NAME = 'pprzEnv'
def run(args):
if args.clean:
if os.path.exists(ENV_NAME):
print("Cleaning previous venv.")
shutil.rmtree(ENV_NAME)
else:
print("No previous venv to clean.")
print("Creating a virtual environment for Paparazzi...")
venv.create(ENV_NAME, with_pip=True, system_site_packages=args.system)
# installing requirements
cmd = [f'./{ENV_NAME}/bin/pip', 'install', '-r' , 'requirements.txt']
result = subprocess.run(cmd, check=False)
if result.returncode:
print("Failed to create venv!")
else:
print("venv successfully created.")
# installing pprzlink
print("Installing pprzlink...")
cmd = [f'./{ENV_NAME}/bin/pip', 'install', '-e' , 'sw/ext/pprzlink/lib/v2.0/python']
result = subprocess.run(cmd, check=False)
if result.returncode:
print("Failed to install pprzlink!")
else:
print("pprzlink successfully installed.")
if not os.path.exists(f'./{ENV_NAME}/bin/calibrate.py'):
os.symlink('../../sw/tools/calibration/calibrate.py', f'./{ENV_NAME}/bin/calibrate.py')
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="This script will setup the python environment for Paparazzi")
parser.add_argument('-s', '--system', action='store_true', help="Use system site packages.")
parser.add_argument('-c', '--clean', action='store_true', help="Delete the previous virtual environment before recreating it.")
args = parser.parse_args()
run(args)