Mercurial > code > home > repos > homeauto
comparison service/iot2/tasks.py @ 1489:a4fb4cc60ae1
get some iot2 tests going
Ignore-this: cdfdf88f445f043aa5aa55f737f6b776
darcs-hash:f0dc8fe99648fd4f7a3870c2b564ae1e4c85fdd9
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Tue, 21 Jan 2020 23:59:45 -0800 |
parents | |
children | e3eceee54937 |
comparison
equal
deleted
inserted
replaced
1488:ae7d65fce483 | 1489:a4fb4cc60ae1 |
---|---|
1 from invoke import task | |
2 from pathlib import Path | |
3 | |
4 @task | |
5 def nim_install(ctx): | |
6 if Path('nim-1.0.4/bin/nim').exists(): | |
7 return | |
8 ctx.run(f'curl https://nim-lang.org/download/nim-1.0.4-linux_x64.tar.xz | xz -dc | tar x') | |
9 | |
10 @task | |
11 def py_install(ctx): | |
12 if Path('env/bin/python').exists(): | |
13 return | |
14 ctx.run(f'mkdir -p env') | |
15 ctx.run(f'virtualenv -p /usr/bin/python3.7 env') | |
16 | |
17 @task(pre=[py_install]) | |
18 def py_deps(ctx): | |
19 pip_install_ran = Path('env/lib/python3.7/site-packages/wheel').stat().st_mtime | |
20 requirements = Path('requirements.txt').stat().st_mtime | |
21 if pip_install_ran > requirements: | |
22 return | |
23 ctx.run(f'env/bin/pip install --quiet --index-url https://projects.bigasterisk.com/ --extra-index-url https://pypi.org/simple -r requirements.txt') | |
24 | |
25 @task(pre=[nim_install]) | |
26 def nim_deps(ctx): | |
27 pkgs = ['nimpy-0.1.0'] | |
28 if all(Path(f'~/.nimble/pkgs/{pkg}').expanduser().exists() for pkg in pkgs): | |
29 return | |
30 plain_names = ' '.join(p.split('-')[0] for p in pkgs) | |
31 ctx.run(f'nim-1.0.4/bin/nimble install {plain_names}', pty=True) | |
32 | |
33 | |
34 @task(pre=[nim_install]) | |
35 def nim_build_x86(ctx): | |
36 ctx.run(f'nim-1.0.4/bin/nim c --out:iot2_linux_x86 iot2_linux.nim', pty=True) | |
37 | |
38 @task | |
39 def arm_cross_compiler_install(ctx): | |
40 ctx.run(f'sudo apt install -y crossbuild-essential-armhf', pty=True) | |
41 | |
42 @task(pre=[nim_install]) | |
43 def nim_build_arm(ctx): | |
44 ctx.run(f'nim-1.0.4/bin/nim c --cpu:arm --out:iot2_linux_arm iot2_linux.nim', pty=True) | |
45 | |
46 @task(pre=[py_deps, nim_build_x86]) | |
47 def local_run(ctx): | |
48 ctx.run(f'./iot2_linux_x86') | |
49 | |
50 | |
51 # pack this into docker for pushing to Pi | |
52 | |
53 # apt install -y sshfs | |
54 # sshfs drewp@10.2.0.110:/my/proj/homeauto/service/iot2 /mnt | |
55 # cd /mnt | |
56 # ./iot2_linux_arm |